Permalink
Browse files

Make Spock Framework the default test framework for Grails 2.3

  • Loading branch information...
1 parent 47d50d5 commit b079427e4dac74644f76fbc642bb97438639061a @graemerocher graemerocher committed Jun 4, 2013
View
@@ -44,7 +44,7 @@ ext {
springLoadedVersion = "1.1.1"
springVersion = "3.2.3.RELEASE"
ehcacheVersion = "2.4.6"
- junitVersion = "4.10"
+ junitVersion = "4.11"
concurrentlinkedhashmapVersion = "1.3.1"
}
@@ -134,7 +134,7 @@ class TestExecutionContext extends ExecutionContext {
@Override
protected List<File> buildMinimalIsolatedClasspath(BuildSettings buildSettings) {
final classpath = super.buildMinimalIsolatedClasspath(buildSettings)
- classpath << buildSettings.testDependencies.find { File f -> f.name.startsWith('junit') }
+ classpath.addAll buildSettings.testDependencies.findAll { File f -> f.name.startsWith('junit') || f.name.contains('spock') || f.name.startsWith('hamcrest') }
classpath.addAll process.findSystemClasspathJars(buildSettings)
return classpath
}
@@ -53,6 +53,13 @@ dependencies {
compile("org.springframework:spring-test:${springVersion}") {
exclude group: 'commons-logging', module:'commons-logging'
}
+
+ compile("org.spockframework:spock-core:${spockVersion}") {
+ exclude group:'junit', module: 'junit-dep'
+ }
+ compile "junit:junit:${junitVersion}", {
+ exclude group:'org.hamcrest', module: 'hamcrest-core'
+ }
}
eclipse {
@@ -1,15 +1,18 @@
-@artifact.package@
-
-import grails.test.mixin.*
-import org.junit.*
+@artifact.package@import grails.test.mixin.TestFor
+import spock.lang.Specification
/**
* See the API for {@link grails.test.mixin.web.ControllerUnitTestMixin} for usage instructions
*/
@TestFor(@artifact.testclass@)
-class @artifact.name@ {
+class @artifact.name@ extends Specification {
+
+ def setup() {
+ }
+
+ def cleanup() {
+ }
- void testSomething() {
- fail "Implement me"
+ void "test something"() {
}
-}
+}
@@ -1,15 +1,18 @@
-@artifact.package@
-
-import grails.test.mixin.*
-import org.junit.*
+@artifact.package@import grails.test.mixin.TestFor
+import spock.lang.Specification
/**
* See the API for {@link grails.test.mixin.domain.DomainClassUnitTestMixin} for usage instructions
*/
@TestFor(@artifact.testclass@)
-class @artifact.name@ {
+class @artifact.name@ extends Specification {
+
+ def setup() {
+ }
+
+ def cleanup() {
+ }
- void testSomething() {
- fail "Implement me"
+ void "test something"() {
}
-}
+}
@@ -1,11 +1,15 @@
-@artifact.package@
-
-import grails.test.mixin.*
+@artifact.package@import grails.test.mixin.Mock
+import spock.lang.Specification
@Mock(@artifact.testclass@)
-class @artifact.name@ {
+class @artifact.name@ extends Specification {
+
+ def setup() {
+ }
+
+ def cleanup() {
+ }
- void testSomething() {
- fail "Implement me"
+ void "test something"() {
}
-}
+}
@@ -1,20 +1,20 @@
-@artifact.package@import static org.junit.Assert.*
-import org.junit.*
+@artifact.package@
+import grails.test.mixin.TestMixin
+import grails.test.mixin.support.GrailsUnitTestMixin
+import spock.lang.*
-class @artifact.name@ {
+/**
+ * See the API for {@link grails.test.mixin.support.GrailsUnitTestMixin} for usage instructions
+ */
+@TestMixin(GrailsUnitTestMixin)
+class @artifact.name@ extends Specification {
- @Before
- void setUp() {
- // Setup logic here
+ def setup() {
}
- @After
- void tearDown() {
- // Tear down logic here
+ def cleanup() {
}
- @Test
- void testSomething() {
- fail "Implement me"
+ void "test something"() {
}
-}
+}
@@ -1,15 +1,18 @@
-@artifact.package@
-
-import grails.test.mixin.*
-import org.junit.*
+@artifact.package@import grails.test.mixin.TestFor
+import spock.lang.Specification
/**
* See the API for {@link grails.test.mixin.services.ServiceUnitTestMixin} for usage instructions
*/
@TestFor(@artifact.testclass@)
-class @artifact.name@ {
+class @artifact.name@ extends Specification {
+
+ def setup() {
+ }
+
+ def cleanup() {
+ }
- void testSomething() {
- fail "Implement me"
+ void "test something"() {
}
-}
+}
@@ -1,15 +1,18 @@
-@artifact.package@
-
-import grails.test.mixin.*
-import org.junit.*
+@artifact.package@import grails.test.mixin.TestFor
+import spock.lang.Specification
/**
* See the API for {@link grails.test.mixin.web.GroovyPageUnitTestMixin} for usage instructions
*/
@TestFor(@artifact.testclass@)
-class @artifact.name@ {
+class @artifact.name@ extends Specification {
+
+ def setup() {
+ }
+
+ def cleanup() {
+ }
- void testSomething() {
- fail "Implement me"
+ void "test something"() {
}
-}
+}
@@ -1,24 +1,19 @@
-@artifact.package@import static org.junit.Assert.*
-
-import grails.test.mixin.*
-import grails.test.mixin.support.*
-import org.junit.*
+@artifact.package@import grails.test.mixin.TestMixin
+import grails.test.mixin.support.GrailsUnitTestMixin
+import spock.lang.Specification
/**
* See the API for {@link grails.test.mixin.support.GrailsUnitTestMixin} for usage instructions
*/
@TestMixin(GrailsUnitTestMixin)
-class @artifact.name@ {
+class @artifact.name@ extends Specification {
- void setUp() {
- // Setup logic here
+ def setup() {
}
- void tearDown() {
- // Tear down logic here
+ def cleanup() {
}
- void testSomething() {
- fail "Implement me"
+ void "test something"() {
}
-}
+}
@@ -4,7 +4,9 @@ configurations {
dependencies {
// Testing
- compile "junit:junit:${junitVersion}"
+ compile "junit:junit:${junitVersion}", {
+ exclude group:'org.hamcrest', module: 'hamcrest-core'
+ }
scripts project(":grails-web"),
project(':grails-docs'),
View
@@ -7,7 +7,10 @@ dependencies {
compile "org.apache.ant:ant-junit:${antVersion}"
// Testing
- compile "junit:junit:${junitVersion}", project(":grails-plugin-converters"), project(":grails-plugin-mimetypes")
+ compile "junit:junit:${junitVersion}", {
+ exclude group:'org.hamcrest', module: 'hamcrest-core'
+ }
+ compile project(":grails-plugin-converters"), project(":grails-plugin-mimetypes")
compile project(":grails-web")
@@ -38,7 +38,7 @@ import org.junit.runners.Suite
*/
class JUnit4GrailsTestType extends GrailsTestTypeSupport {
- static final List<String> SUFFIXES = ["Test", "Tests"].asImmutable()
+ static final List<String> SUFFIXES = ["Test", "Tests", "Spec"].asImmutable()
protected suite
protected GrailsTestMode mode
@@ -132,7 +132,7 @@ createIntegrationTest = { Map args = [:] ->
def superClass = args["superClass"] ?: "GroovyTestCase"
createArtifact(
name: args["name"],
- suffix: "${args['suffix']}Tests",
+ suffix: "${args['suffix']}Spec",
type: args.testType ?: args['suffix'],
path: "test/integration",
superClass: superClass,
@@ -144,7 +144,7 @@ createUnitTest = { Map args = [:] ->
def superClass = args["superClass"] ?: "GrailsUnitTestCase"
createArtifact(
name: args["name"],
- suffix: "${args['suffix']}Tests",
+ suffix: "${args['suffix']}Spec",
type: args.testType ?: args['suffix'],
path: "test/unit",
superClass: superClass,

0 comments on commit b079427

Please sign in to comment.