Grails 1.3 upgrades the bundles JUnit to the newer JUnit 4 API. However, the test template used to generate classes by the Grails create-* scripts is still very JUnit 3-ish. Here's a replacement that will generate a skeleton test using JUnit 4 conventions:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@artifact.package@import grails.test.* | |
import org.junit.* | |
import static org.junit.Assert.* | |
import static org.hamcrest.CoreMatchers.* | |
import static org.junit.matchers.JUnitMatchers.* | |
class @artifact.name@ { | |
@Before void setUp() { | |
} | |
@After void tearDown() { | |
} | |
@Test void something() { | |
} | |
} |
To use this just run grails install-templates
then copy the contents over the file src/templates/artifacts/Tests.groovy. You can delete anything else in the src/templates directory that you don't need. Then every time you use a Grails command such as grails create-service foo
the generated test will use the JUnit 4 template.