尝试运行集成测试会抛出null异常,除非我执行grails clean。
我执行以下命令序列
> grails > test-app ShowIn // throws NullPointer exception > clean > test-app ShowIn // now the test magically passes
在命令序列期间,我没有在代码中改变任何内容。
我正在运行grails 2.3.7,groovy 2.2.0和jvm 1.6.0_35。
下面有更详细的输出:
| Completed 1 integration test, 1 failed in 0m 0s | Compiling 1 source files..... | Compiling 1 source files.... | Compiling 1 source files..... | Error Fatal error running tests: null (Use --stacktrace to see the full trace) | Tests FAILED - view reports in C:\mroot\gplay\projects\ShowAdapterPOC4\target\test-reports | Error Error running script test-app ShowIn: java.lang.NullPointerException (Use --stacktrace to see the full trace) grails> exit | Goodbye | Application cleaned. | Enter a script name to run. Use TAB for completion: grails> test-app ShowIn | Compiling 10 source files | Compiling 16 source files..... | Compiling 16 source files.... | Compiling 16 source files.... | Running 1 integration test... 1 of 1 2014-04-21 19:44:57,432 [main] DEBUG hibernate.SQL - /* criteria query */ select this_.ShowId as ShowId0_0_ from Shows this_ | Completed 1 integration test, 0 failed in 0m 0s | Tests PASSED - view reports in C:\mroot\gplay\projects\ShowAdapterPOC4\target\test-reports grails> Here's the test package showadapterpoc4 import spock.lang.* import grails.test.spock.IntegrationSpec class ShowInSpec extends IntegrationSpec { //class ShowInSpec extends Specification{ ShowInCongress showInCongress def setup() { } def cleanup() { } void "find shows in congress db"() { setup: def shows = ShowInCongress.list() expect: shows.size() > 0 } }
每次单元测试工作正常,但除非grails清理,否则无法找到集成测试。
测试正在进入域类。每次更改域类时我是否必须干净?
我可能做错了什么?每次需要运行集成测试时,如何避免grails干净?