从 eclipse (STS) 和 grails 运行时,我得到不同的测试结果。
在 grails 下,我的测试错误(即甚至不运行)带有 ClassNotFoundException
在eclipse中他们成功运行。
(从 grails FWIW 运行时,run-app 仍然可以正常工作。)
测试已经在这两种环境中进行了几天。然后我删除了一些我不需要的文件(域。控制器和它们的单元测试)现在我有一个问题。
版本:
ubuntu 10.04
eclipse
eclipse / SpringToolSuite 3.4.0
- groovy compiler: groovy 2.07
- grails location: /home/nick/grails-2.3.6
- JDK compliance level 1.6
- JAVA_HOME=/usr/lib/jvm/java-6-openjdk
grails 2.3.6
- GRAILS_HOME=/home/nick/grails-2.3.6
- JAVA_HOME=/usr/lib/jvm/java-6-openjdk
日食/SpringToolSuite 3.4.0
从 Eclipse / STS 内部看,一切都很好
select project
run as > junit test
runs 24 tests in 3 test classes
all succeed
圣杯 2.3.6
但是从终端的 grails 内部,测试不再运行。
grails> test-app
| Compiling 2 source files.
| Error Fatal error running tests: Could not load class in test type 'unit' (Use --stacktrace to see the full trace)
| Compiling 2 source files..
| Tests FAILED - view reports in /home/nick/grails-2.3.6-workspace/imca2/target/test-reports
浏览测试报告显示:未执行任何测试。
添加--stacktrace 没有区别,没有提供堆栈跟踪,它仍然建议我添加--stacktrace。
grails test-app --stacktrace | tee /tmp/out
给
| Loading Grails 2.3.6
| Configuring classpath
| Configuring classpath.
| Environment set to test
| Environment set to test.
| Environment set to test..
| Environment set to test...
| Environment set to test....
| Environment set to test.....
| Running without daemon...
| Compiling 1 source files
| Compiling 1 source files.
| Error Fatal error running tests: Could not load class in test type 'unit' (NOTE: Stack trace has been filtered. Use --verbose to see entire trace.)
java.lang.RuntimeException: Could not load class in test type 'unit'
at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1254)
at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1254)
at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1254)
at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1254)
at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1254)
Caused by: java.lang.ClassNotFoundException: com.ubergen.AdvocacyStaffSpec
... 5 more
| Error Fatal error running tests: Could not load class in test type 'unit'
| Compiling 1 source files..
| Tests FAILED - view reports in /home/nick/grails-2.3.6-workspace/imca2/target/test-reports
| Error Error running forked test-app: Could not load class in test type 'unit' (NOTE: Stack trace has been filtered. Use --verbose to see entire trace.)
java.lang.RuntimeException: Could not load class in test type 'unit'
at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1254)
at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1254)
at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1254)
at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1254)
at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1254)
Caused by: java.lang.ClassNotFoundException: com.ubergen.AdvocacyStaffSpec
... 5 more
| Error Error running forked test-app: Could not load class in test type 'unit'
| Error Forked Grails VM exited with error
我首先尝试过 grails clean and clean-all。然后 test-app 重新编译所有内容,但这没有什么区别 - eclipse 仍然成功运行测试,grails 仍然错误而不运行任何测试;我运行它们的顺序并不重要。
我运行测试的顺序也没有任何区别。
我应该怎么办?