简体   繁体   English

Maven:从命令行添加测试目录

[英]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.

相关问题 Maven TestNG 测试未从命令行运行 - Maven TestNG Test not running from Command Line Maven:如何从命令行更改目标目录的路径? - Maven: How to change path to target directory from command line? Maven不会从命令行生成测试类 - Maven does not generate test classes from command line 无法从 maven 命令行调用 cucumber junit 测试 - Unable to invoke cucumber junit test from maven command line 无法使用标签从命令行执行Maven测试? - Cannot execute maven test from command line using tags? Maven TestNG - 无法从命令行指定测试套件 - Maven TestNG - unable to specify test suite from command line 将参数添加到从命令行调用的 Maven Enforcer Rules - Add parameters to Maven Enforcer Rules called from the command line 使用Maven将依赖项下载到命令行上的目录 - Using Maven to download dependencies to a directory on the command line 如何从我自己的Maven库中修改一个项目的Maven测试执行阶段的命令行arguments? - How to modify the command line arguments of the Maven test execution phase of a project from my own Maven library? 使用命令行选项使用maven跳过单个测试 - Skip single test with maven with command line options
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM