我正在使用 intellij idea 11 开发一个 java 项目。
我在项目下有各种模块,例如 com.abc 有 src 和 test 文件夹。测试文件夹是项目的测试路由文件夹。该文件夹下有各种测试用例。
现在我需要编写一个新模块,它有一个 java 类,可以调用各种模块中的测试用例。我没有找到办法。
我创建了一个模块,例如 com.abtestsuite,并添加了对存在相应测试用例的其他模块的依赖项。
请建议我更进一步?我可以使用 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,具有自己的覆盖率和检查。