我正在使用intellij idea 11开发一个java项目。
我在项目下有各种模块,例如com.a.b.c,其中有src和测试文件夹。测试文件夹为项目的测试路由文件夹。在那个文件夹下有各种各样的测试用例。
现在我需要写一个新的模块,它有一个java类,在各个模块中调用测试用例。我找不到办法。
我已经创建了一个模块,例如com.a.b.t testsuite,并添加了对其他模块的依赖,其中各自的测试用例存在。
请给我建议一条更远的路。我可以使用JUnitCore类吗?我不知道如何使用它。
正如其他人建议的那样,我建议将您的项目转换为Maven项目。
然后在POM中创建一个配置文件,并使用cobertura插件,如下所示:
<profile>
<id>testcheck</id>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
<version>2.5.1</version>
<configuration>
<check>
<branchRate>0</branchRate>
<lineRate>0</lineRate>
<haltOnFailure>true</haltOnFailure>
<totalBranchRate>90</totalBranchRate>
<totalLineRate>90</totalLineRate>
<packageLineRate>0</packageLineRate>
<packageBranchRate>0</packageBranchRate>
</check>
</configuration>
<executions>
<execution>
<phase>verify</phase>
<goals>
<goal>clean</goal>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
这真的是最好的方法。特别是因为你在项目中包含的每个模块也可以有自己的POM,有自己的覆盖率和检查。