jtanistra / spock

Automatically exported from code.google.com/p/spock
0 stars 0 forks source link

Incompatible mockDomain Return Type #194

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem? If possible, provide source code and
stack trace.
1. Create a unit test for testing constraints (see code below)
2. grails test-app :spock

| Error Compilation error compiling [spock] tests: startup failed:
/home/erturne/myapp/test/unit/foo/UserTests.groovy: -1: The return
type of java.lang.Object mockDomain(java.lang.Class, java.util.List)
in foo.UserTests is incompatible with void mockDomain(java.lang.Class,
java.util.List) in grails.plugin.spock.UnitSpec
. At [-1:-1]  @ line -1, column -1.

package foo

import grails.plugin.spock.*
import grails.test.mixin.*

/**
 * See the API for {@link
grails.test.mixin.domain.DomainUnitTestMixin} for usage instructions
 */
@TestFor(User)
class UserTests extends UnitSpec {

       def "first name must not violate constraints"() {
               setup:
               mockForConstraintsTests(User)

               when:
               def user = new User(firstName: firstName, lastName: 'Doe')
               user.validate()

               then:
               user.hasErrors() == !valid

               where:
               firstName               | valid
               null                    | false   // Must not be null
               ''                      | false   // Must not be blank
               '012345678901234567891' | false   // Must not exceed 20 characters
               'John'                  | true    // Okay
       }
}

What version of Spock and Groovy are you using?
Groovy: 1.8
Grails: 2.0.0M1
Spock plugin: 0.6-SNAPSHOT

Please provide any additional information below. You can also assign
labels.

Original issue reported on code.google.com by ertu...@gmail.com on 10 Aug 2011 at 12:14

GoogleCodeExporter commented 8 years ago
Got the stack trace:

    at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)
    at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
    at org.codehaus.gant.GantBuilder.invokeMethod(GantBuilder.java:93)
    at _GrailsTest_groovy$_run_closure3.doCall(_GrailsTest_groovy:261)
    at _GrailsTest_groovy$_run_closure2.doCall(_GrailsTest_groovy:240)
    at _GrailsTest_groovy$_run_closure1_closure21.doCall(_GrailsTest_groovy:190)
    at _GrailsTest_groovy$_run_closure1.doCall(_GrailsTest_groovy:179)
    at org.codehaus.gant.GantMetaClass.invokeMethod(GantMetaClass.java:127)
    at org.codehaus.gant.GantBinding$_initializeGantBinding_closure5_closure16_closure18.doCall(GantBinding.groovy:185)
    at org.codehaus.gant.GantBinding$_initializeGantBinding_closure5_closure16_closure18.doCall(GantBinding.groovy)
    at org.codehaus.gant.GantBinding.withTargetEvent(GantBinding.groovy:90)
    at org.codehaus.gant.GantBinding.this$4$withTargetEvent(GantBinding.groovy)
    at org.codehaus.gant.GantBinding$_initializeGantBinding_closure5_closure16.doCall(GantBinding.groovy:185)
    at org.codehaus.gant.GantBinding$_initializeGantBinding_closure5_closure16.doCall(GantBinding.groovy)
    at org.codehaus.gant.GantMetaClass.invokeMethod(GantMetaClass.java:127)
    at TestApp$_run_closure1.doCall(TestApp.groovy:82)
    at org.codehaus.gant.GantMetaClass.invokeMethod(GantMetaClass.java:127)
    at org.codehaus.gant.GantBinding$_initializeGantBinding_closure5_closure16_closure18.doCall(GantBinding.groovy:185)
    at org.codehaus.gant.GantBinding$_initializeGantBinding_closure5_closure16_closure18.doCall(GantBinding.groovy)
    at org.codehaus.gant.GantBinding.withTargetEvent(GantBinding.groovy:90)
    at org.codehaus.gant.GantBinding.this$4$withTargetEvent(GantBinding.groovy)
    at org.codehaus.gant.GantBinding$_initializeGantBinding_closure5_closure16.doCall(GantBinding.groovy:185)
    at org.codehaus.gant.GantBinding$_initializeGantBinding_closure5_closure16.doCall(GantBinding.groovy)
    at gant.Gant$_dispatch_closure5.doCall(Gant.groovy:381)
    at gant.Gant$_dispatch_closure7.doCall(Gant.groovy:415)
    at gant.Gant$_dispatch_closure7.doCall(Gant.groovy)
    at gant.Gant.withBuildListeners(Gant.groovy:427)
    at gant.Gant.this$2$withBuildListeners(Gant.groovy)
    at gant.Gant$this$2$withBuildListeners.callCurrent(Unknown Source)
    at gant.Gant.dispatch(Gant.groovy:415)
    at gant.Gant.this$2$dispatch(Gant.groovy)
    at gant.Gant.invokeMethod(Gant.groovy)
    at gant.Gant.executeTargets(Gant.groovy:591)
    at gant.Gant.executeTargets(Gant.groovy:590)

Original comment by ertu...@gmail.com on 10 Aug 2011 at 12:43