keskiviikko 25. helmikuuta 2009

Missing the green bar developing Grails apps in Eclipse?

I've been missing the green bar developing Grails apps in Eclipse.
I found a solution to the problem.

Instructions (tested with Grails 1.1-RC1):

Creating Eclipse Run Configuration

1. Open the Run Configurations dialog (Run -> Run Configurations. Switch to Java perspective first. Make sure you've added the GRAILS_HOME classpath variable for a new Grails project.)

2. Browse to the item "Junit" and double click on it. It will create a new Junit run configuration.

3. Select "Run a single test"

4. Enter "groovy.util.GroovyTestSuite" as the Test class

5. Switch to "Arguments" tab.

6. In "VM arguments" field enter "-Dtest=${resource_loc}"

7. Click close

Creating and running a test

1. In the command line: grails create-unit-test GrailsJunit

2. Refresh Eclipse view

3. Open the Junit test

4. Open the Run Configurations dialog (Run -> Run Configurations)

5. Select the Junit run configuration you've created recently.

6. Click "Run"

Changing the behaviour of the Run button's default action

In Eclipse 3.4, the default behaviour of clicking the run button is "contextual".
It's easier to run the test if you can just click the Run button.

1. Open "Window->Preferences"
2. Write "launching" in the filter text box.
3. Select "Always launch the previously launched application" in the "Launch Operation" section.

Now you can execute the test by opening the file and just click the run button. Cool!

Re-run button in the JUnit panel

You won't be able to re-run the test by clicking the button in the JUnit panel.
If you want it to work, you will have to create separate launchers for each test.
Another solution is to edit the launcher's configuration each time you start developing a new class.
This can be done by setting the "VM arguments" property to something like this:

Ei kommentteja:

Lähetä kommentti