【问题标题】:Maven surefire suiteXmlFile possibilitiesMaven surefire suiteXmlFile 可能性
【发布时间】:2017-02-01 08:34:12
【问题描述】:

目前我有可能使用这样的surefire插件在maven上运行多个测试:

mvn clean test -Dsurefire.suiteXmlFiles=test1.xml,test2.xml,test3.xml,test4.xml,...

很好,但我想知道是否可以通过读取包含这些test.xml 的文件来改进它。

我想这样做是为了提高可读性,因为这些测试的路径可能很长。

所以我想做这样的事情,而不是这样:

mvn clean test -Dsurefire.suiteXmlFiles=file.txt

在我的file.txt

path/to/my/test1.xml,path/to/my/test2.xml,path/to/my/test3.xml,...

【问题讨论】:

    标签: maven testing maven-surefire-plugin


    【解决方案1】:

    是的,你必须使用属性插件:

    插件

    <plugins>
          <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>properties-maven-plugin</artifactId>
            <version>1.0.0</version>
            <executions>
              <execution>
                <phase>initialize</phase>
                <goals>
                  <goal>read-project-properties</goal>
                </goals>
                <configuration>
                  <files>
                    <file>${propertiesFile}</file>
                  </files>
                </configuration>
              </execution>
            </executions>
          </plugin>
        </plugins>
    

    属性文件

    test.files = path/to/my/test1.xml,path/to/my/test2.xml,path/to/my/test3.xml
    

    万无一失

    <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>2.19.1</version>
            <configuration>
              <suiteXmlFiles>
                <suiteXmlFile>${test.files}</suiteXmlFile>
              </suiteXmlFiles>
            </configuration>
          </plugin>
    

    命令

    mvn -DpropertiesFile=props.txt properties:read-project-properties clean test  
    

    【讨论】:

    • 嘿,你如何定义属性文件的路径?
    • 你在哪里设置这些变量:${propertiesFile} && ${test.files}
    • 我已经更新了 mvn 命令。现在试试。 test.files 在属性文件中定义
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-12-20
    • 2016-03-05
    • 2017-11-04
    • 1970-01-01
    相关资源
    最近更新 更多