2012-05-02 2 views
1

Я просто клонировал пример проекта geb-grails-example и обратился к ошибке, связанной с Spock.Ошибка Spock: не удается найти поле общего экземпляра

При работе с Grails (2.0.3) команда test-app, я получаю следующее сообщение об ошибке:

| Server running. Browse to http://localhost:8080/geb-example-grails 
| Server stopped 
| Tests PASSED - view reports in target\test-reports 
| Error Error running script test-app --stacktrace: cannot find shared instance field (NOTE:   Stack trace has been filtered. Use --verbose to see entire trace.) 
org.spockframework.util.InternalSpockError: cannot find shared instance field 
at org.spockframework.runtime.SpecInfoBuilder.getSharedInstanceField(SpecInfoBuilder.java:119) 
at org.spockframework.runtime.SpecInfoBuilder.buildSharedInstanceField(SpecInfoBuilder.java:107) 
at org.spockframework.runtime.SpecInfoBuilder.doBuild(SpecInfoBuilder.java:58) 
at org.spockframework.runtime.SpecInfoBuilder.build(SpecInfoBuilder.java:42) 
at org.spockframework.runtime.Sputnik.getSpec(Sputnik.java:78) 
at org.spockframework.runtime.Sputnik.runExtensionsIfNecessary(Sputnik.java:86) 
at org.spockframework.runtime.Sputnik.getDescription(Sputnik.java:55) 
at org.junit.runners.Suite.describeChild(Suite.java:123) 
at org.junit.runners.Suite.describeChild(Suite.java:24) 
at org.junit.runners.ParentRunner.getDescription(ParentRunner.java:290) 
at org.junit.runner.JUnitCore.run(JUnitCore.java:156) 
at org.junit.runner.JUnitCore.run(JUnitCore.java:136) 
at org.junit.runner.JUnitCore.run(JUnitCore.java:117) 
at com.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1237) 
at grails.plugin.spock.test.GrailsSpecTestType.doRun(GrailsSpecTestType.groovy:73) 
at com.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1237) 
at _GrailsTest_groovy$_run_closure4.doCall(_GrailsTest_groovy:290) 
at com.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1237) 
at _GrailsTest_groovy$_run_closure4.call(_GrailsTest_groovy) 
at com.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1237) 
at _GrailsTest_groovy$_run_closure2.doCall(_GrailsTest_groovy:248) 
at com.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1237) 
at _GrailsTest_groovy$_run_closure1_closure21.doCall(_GrailsTest_groovy:195) 
at com.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1237) 
at _GrailsTest_groovy$_run_closure1.doCall(_GrailsTest_groovy:184) 
at com.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1237) 
at org.codehaus.gant.GantMetaClass.invokeMethod(GantMetaClass.java:133) 
at com.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1237) 
at org.codehaus.gant.GantMetaClass.invokeMethod(GantMetaClass.java:133) 
at org.codehaus.gant.GantBinding$_initializeGantBinding_closure5_closure16_closure18.doCall(GantBinding.groovy:185) 
at com.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1237) 
at org.codehaus.gant.GantBinding$_initializeGantBinding_closure5_closure16_closure18.doCall(GantBinding.groovy) 
at com.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1237) 
at java_util_concurrent_Callable$call.call(Unknown Source) 
at org.codehaus.gant.GantBinding.withTargetEvent(GantBinding.groovy:90) 
at org.codehaus.gant.GantBinding.this$4$withTargetEvent(GantBinding.groovy) 
at com.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1237) 
at org.codehaus.gant.GantBinding$_initializeGantBinding_closure5_closure16.doCall(GantBinding.groovy:185) 
at com.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1237) 
at org.codehaus.gant.GantBinding$_initializeGantBinding_closure5_closure16.doCall(GantBinding.groovy) 
at com.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1237) 
at com.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1237) 
at org.codehaus.gant.GantMetaClass.invokeMethod(GantMetaClass.java:133) 
at TestApp$_run_closure1.doCall(TestApp.groovy:82) 
at com.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1237) 
at org.codehaus.gant.GantMetaClass.invokeMethod(GantMetaClass.java:133) 
at com.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1237) 
at org.codehaus.gant.GantMetaClass.invokeMethod(GantMetaClass.java:133) 
at org.codehaus.gant.GantBinding$_initializeGantBinding_closure5_closure16_closure18.doCall(GantBinding.groovy:185) 
at com.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1237) 
at org.codehaus.gant.GantBinding$_initializeGantBinding_closure5_closure16_closure18.doCall(GantBinding.groovy) 
at com.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1237) 
at java_util_concurrent_Callable$call.call(Unknown Source) 
at org.codehaus.gant.GantBinding.withTargetEvent(GantBinding.groovy:90) 
at org.codehaus.gant.GantBinding.this$4$withTargetEvent(GantBinding.groovy) 
at com.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1237) 
at org.codehaus.gant.GantBinding$_initializeGantBinding_closure5_closure16.doCall(GantBinding.groovy:185) 
at com.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1237) 
at org.codehaus.gant.GantBinding$_initializeGantBinding_closure5_closure16.doCall(GantBinding.groovy) 
at com.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1237) 
at java_util_concurrent_Callable$call.call(Unknown Source) 
at gant.Gant$_dispatch_closure5.doCall(Gant.groovy:381) 
at com.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1237) 
at gant.Gant$_dispatch_closure7.doCall(Gant.groovy:415) 
at com.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1237) 
at gant.Gant$_dispatch_closure7.doCall(Gant.groovy) 
at com.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1237) 
at java_util_concurrent_Callable$call.call(Unknown Source) 
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$this$2$withBuildListeners.callCurrent(Unknown Source) 
at gant.Gant.dispatch(Gant.groovy:415) 
at gant.Gant.this$2$dispatch(Gant.groovy) 
at com.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1237) 
at gant.Gant.invokeMethod(Gant.groovy) 
at gant.Gant.executeTargets(Gant.groovy:591) 
at com.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1237) 
at gant.Gant.executeTargets(Gant.groovy:590) 
at com.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1231) 
| Error Error running script test-app --stacktrace: cannot find shared instance field 

Любая помощь или указатель будет высоко оценен,

Спасибо заранее

Notes :

Я пользуюсь

Вариант Geb равен 0,7, а версия Spock - 0,6

+0

Вы видели [это] (HTTP: //grails.1312388.n4.nabble .com/Problem-in-testing-my-controller-in-spock-td4495752.html) –

+0

Да, я написал свой тест на основе того, что я прочитал из этой темы. Спасибо за проверку. – ontk

ответ

0

Я отменил репо на моей новой системе и все тесты прошли. Я не знаю причину предыдущей ошибки. Закрытие вопроса.

1

У меня такая же проблема (с использованием Geb 0.7.0, Spock 0.6, Grails 2.0.3 & Groovy 1.8.6). Один обходной путь, который я нашел, - это изменить спецификацию, чтобы перейти от GebSpec вместо GebReportingSpec. Тесты проходят после этого изменения - но я не знаю, какие долгосрочные эффекты этого (я довольно новичок в этом стеке).

1

Попробуйте запустить тест, используя -noreloading флаг:

grails -noreloading test-app

0
grails clean 
grails compile 
grails package 

очистили это для меня

Смежные вопросы