[英]Run tests only in test folder
I have a test project in java, that runs all tests found in the projects listed as dependencies for this project. 我在Java中有一个测试项目,该项目运行在项目中找到的所有测试,并列为该项目的依赖项。
@RunWith(ClasspathSuite.class)
@ClassnameFilters({ "com.example.*_Test" })
public class AllRegularTests {
// nothing to do
}
My tests are usually in the test/
folder not in the src/
我的测试通常在test/
文件夹中,而不在src/
How can I make the test suite look only for classes in test/
, and not in src/
? 如何使测试套件仅查找test/
类,而不查找src/
?
Maybe you can do it with the testSourceDirectory definition but I'm not sure. 也许您可以使用testSourceDirectory定义来做到这一点,但我不确定。
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<testSourceDirectory>${basedir}/src/main/java/</testSourceDirectory>
<testClassesDirectory>${project.build.directory}/classes/</testClassesDirectory>
</configuration>
</plugin>
</plugins>
</build>
Few things seems to be wrong here : 这里似乎没有什么错:
Wrong /my_program/src/main/java/NotTest.java /my_program/src/main/java/NotTest.java 错误
Right /my_program/src/test/java/MyTest.java 正确的 /my_program/src/test/java/MyTest.java
Also, check if your test classes directory (eg src/test/java) corresponds to directory listed in property in your pom.xml under property. 另外,检查您的测试类目录(例如src / test / java)是否对应于pom.xml中property属性下列出的目录。 Took me a while to find that. 花了我一段时间才能找到那个。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.