[英]Maven: Add Test Directory From Command Line
Is there a way to include a test folder for Maven to compile from the command line? 有没有一种方法可以包含一个测试文件夹,以便Maven从命令行进行编译?
I have a set of tests that are in a folder that are not part of the standard set of unit and integration tests. 我在文件夹中有一组测试,这些测试不属于标准的单元测试和集成测试。 These tests are still useful to run individually until the needed integration tests are built.
在构建所需的集成测试之前,这些测试对于单独运行仍然很有用。 In Eclipse, I can run these tests individually by right clicking on them and running them as a JUnit test.
在Eclipse中,我可以通过右键单击它们并将它们作为JUnit测试运行来单独运行这些测试。 I am finding that I often want to run more than one test, so I am trying to run them from Maven on the command line.
我发现我经常想运行多个测试,因此我试图在命令行上从Maven运行它们。 In Maven I can do something like this:
在Maven中,我可以执行以下操作:
mvn -Dtest=OldTest,OlderTest test
The problem I think I have is that the folder that these tests sit in is not listed as part of the set of test files that need to compile in the POM. 我想我遇到的问题是,这些测试所在的文件夹没有作为需要在POM中编译的测试文件集的一部分列出。 I would like to temporarily add the folder, run the tests, and remove the folder without modifying the POM.
我想临时添加文件夹,运行测试,然后删除文件夹而不修改POM。
I use the Build Helper plugin to add in integration test sources when a certain profile has been activated, for example: 当某个配置文件被激活时,我使用Build Helper插件添加集成测试源,例如:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.4</version>
<executions>
<execution>
<id>add-test-source</id>
<phase>generate-test-sources</phase>
<goals>
<goal>add-test-source</goal>
</goals>
<configuration>
<sources>
<source>src/it/java</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
Perhaps you can do something similar? 也许您可以做类似的事情?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.