关于编写一个Java类来执行项目其他模块中的测试类的建议

关于编写一个Java类来执行项目其他模块中的测试类的建议,java,junit,Java,Junit,我正在使用intellij idea 11开发一个java项目 我在项目下有各种模块,例如com.a.b.c,其中包含src和test文件夹。测试文件夹是项目的测试路由文件夹。该文件夹下有各种测试用例 现在我需要编写一个新的模块,它有一个java类来调用各个模块中的测试用例。我没有找到办法 我已经创建了一个模块,例如com.a.b.testsuite,并添加了对其他模块的依赖性,这些模块都有相应的测试用例 请再给我建议一条路好吗?我可以使用JUnitCore类吗?我不知道如何使用它 正如大家所建

我正在使用intellij idea 11开发一个java项目

我在项目下有各种模块,例如com.a.b.c,其中包含src和test文件夹。测试文件夹是项目的测试路由文件夹。该文件夹下有各种测试用例

现在我需要编写一个新的模块,它有一个java类来调用各个模块中的测试用例。我没有找到办法

我已经创建了一个模块,例如com.a.b.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>

测试检查
org.codehaus.mojo
cobertura maven插件
2.5.1
0
0
真的
90
90
0
0
验证
清洁的
检查

这确实是最好的办法。尤其是因为项目中包含的每个模块也可以有自己的POM,有自己的覆盖率和检查。

为什么要重新发明轮子?使用maven构建您的项目,它将在每个模块中运行测试,作为构建过程的一部分;最终目标是什么?我想使用intellij代码覆盖率工具计算代码覆盖率。所以,我认为有一个程序来运行所有的测试用例可以帮助我有一个程序来运行所有模块的测试用例并获得代码覆盖率。你可以使用cobertura插件和maven来评估你的代码覆盖率。