【发布时间】:2012-09-12 02:19:52
【问题描述】:
我有一个大型 grails 项目,拆分成几个“就地”插件,以保持良好和模块化。我的一个插件,称为“核心服务”,包含我所有的域类,以及在一个抽象测试类(添加模拟域实例等)中的一些不错的设置工作,由许多单元测试共享。
这对于也存在于插件中的单元测试来说非常棒,但我想使用该抽象测试类在使用该插件的其他 grails 项目的测试中设置模拟数据。运行测试时,插件的测试类似乎不包含在类路径中。有没有办法让 Grails 包含它们?:
//this abstract test class is in the core service plugin's test directory. My IDE has no problem with this import
import com.myproject.coreservices.service.AbstractGiftInstanceRelatedUnitTest
//this test class is in the project that uses the plugin
class ClaimGiftControllerTests extends AbstractGiftInstanceRelatedUnitTest {
.. my tests
}
以及输出(不重要的部分去掉):
| Error Compilation error compiling [unit] tests: startup failed:
...../test/unit/com/myproject/ClaimGiftControllerTests.groovy: 3: unable to resolve class com.myproject.coreservices.service.AbstractGiftInstanceRelatedUnitTest
@ line 3, column 1.
import com.myproject.coreservices.service.AbstractGiftInstanceRelatedUnitTest
^
【问题讨论】:
标签: unit-testing grails classpath