2

I am facing an issue in the Spock framework. I have upgraded my application from Grails 3 to Grails 4. I have used Mixin in Grails 3 but since Grails 3.3, mixin is removed. Now I am using the Spock framework. I have created a sample Domain class and a Test Class but I am getting this error while running my test case:

java.lang.AbstractMethodError: Receiver class org.grails.testing.gorm.spock.DataTestSetupSpecInterceptor does not define or inherit an implementation of the resolved method 'abstract java.lang.Object getProperty(java.lang.String)' of interface groovy.lang.GroovyObject.

    at groovy.lang.Closure.getPropertyTryThese(Closure.java:313)
    at groovy.lang.Closure.getPropertyOwnerFirst(Closure.java:307)
    at groovy.lang.Closure.getProperty(Closure.java:296)
    at org.grails.testing.gorm.spock.DataTestSetupSpecInterceptor.setupDataTestBeans_closure1(DataTestSetupSpecInterceptor.groovy:39)
    at org.grails.testing.gorm.spock.DataTestSetupSpecInterceptor.setupDataTestBeans_closure1(DataTestSetupSpecInterceptor.groovy)
    at groovy.lang.Closure.call(Closure.java:405)
    at groovy.lang.Closure.call(Closure.java:399)
    at grails.spring.BeanBuilder.invokeBeanDefiningClosure(BeanBuilder.java:759)
    at grails.spring.BeanBuilder.beans(BeanBuilder.java:588)
    at org.grails.testing.GrailsUnitTest$Trait$Helper.defineBeans(GrailsUnitTest.groovy:97)
    at org.grails.testing.gorm.spock.DataTestSetupSpecInterceptor.setupDataTestBeans(DataTestSetupSpecInterceptor.groovy:38)
    at org.grails.testing.gorm.spock.DataTestSetupSpecInterceptor.configureDataTest(DataTestSetupSpecInterceptor.groovy:66)
    at org.grails.testing.gorm.spock.DataTestSetupSpecInterceptor.intercept(DataTestSetupSpecInterceptor.groovy:31)
    at org.spockframework.runtime.extension.MethodInvocation.proceed(MethodInvocation.java:97)
    at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
    at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:69)
    at com.intellij.rt.junit.IdeaTestRunner$Repeater$1.execute(IdeaTestRunner.java:38)
    at com.intellij.rt.execution.junit.TestsRepeater.repeat(TestsRepeater.java:11)
    at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:35)
    at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:235)
    at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:54)

Below are my Spec Class and Domain Class

class Person {

    String firstName
    String lastName
    static constraints = {
    }
}
class PersonSpec extends Specification implements DomainUnitTest<Person> {

    def setup() {
    }

    def cleanup() {
    }

    void "test something"() {
        expect:"fix me"
            true == false
    }
}

Can someone please help me out? TIA

Zaid Khan
  • 21
  • 1
  • I tried to recreate that problem at https://github.com/jeffbrown/zaidkhandomaintest and was unable to do so. The test at https://github.com/jeffbrown/zaidkhandomaintest/blob/57e6421c3cd3c0f90fa403d33a8dea8da467a2d1/src/test/groovy/zaidkhandomaintest/PersonSpec.groovy fails because of `true == false`, not with an exception. Does the exception manifest in your environment when you run the test in my repo? – Jeff Scott Brown Jul 08 '22 at 15:34
  • Hi Jeff, thanks for trying it. I am still getting the exception. I am using IntelliJ Idea – Zaid Khan Jul 08 '22 at 20:15
  • I expect the problem is related to how your run config is created in IntelliJ. Does the exception happen if you run `gradlew test` and leave IntelliJ out of it? – Jeff Scott Brown Jul 09 '22 at 15:57
  • FYI, when I remove the DomainUnitTest implementation from PersonSpec, it worked fine. Any implementation related to spock framework causing this issue like implementing ControllerUniTest, DomainUnitTest, ServiceUnitTest etc – Zaid Khan Jul 11 '22 at 12:26
  • ./gradlew test also cauging issue – Zaid Khan Jul 11 '22 at 12:27
  • "./gradlew test also cauging issue" - i cannot reproduce that. See https://gist.github.com/jeffbrown/2f9c3da3ff6c62d3bf79c2d4d14596a6. Which JDK are you using and what operating system? – Jeff Scott Brown Jul 11 '22 at 14:37
  • Linux mint and JDK 11 – Zaid Khan Jul 12 '22 at 16:32

0 Answers0