0

JUnit 测试的测试结果有一个properties带有一堆属性的标签。记录的内容似乎由每个测试执行者自行决定。

我想进一步处理 XML 文件,所以每次都拥有相同的密钥会非常好。因为maven-surefire-plugin这很简单:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-surefire-plugin</artifactId>
    <configuration>
        <systemPropertyVariables>
            <propertyName>propertyValue1</propertyName>
        </systemPropertyVariables>
    </configuration>
</plugin>

这会将行添加<property name="propertyName" value="propertyValue1"/>到 XML 结果文件中。

对于tycho-surefire-plugin,我尝试了以下方法:

<plugin>
    <groupId>org.eclipse.tycho</groupId>
    <artifactId>tycho-surefire-plugin</artifactId>
    <version>${tycho-version}</version>
    <configuration>
        <systemPropertyVariables>
            <propertyName>propertyValue1</propertyName>
        </systemPropertyVariables>

        <systemProperties>
            <property>
                <name>propertyName</name>
                <value>propertyValue2</value>
            </property>
        </systemProperties>

        <argLine>-DpropertyName=propertyValue3</argLine>
    </configuration>
</plugin>

...但是这些值都没有打印在 XML 结果中。

如何使用 向 JUnit 测试结果添加信息tycho-surefire-plugin

4

1 回答 1

1

您应该使用地图的州的文档:tycho-surefire-plugin<systemProperties>

<configuration>
  <systemProperties>
    <propertyName>propertyValue1</propertyName>
  </systemProperties>
</configuration>

这将使用-DpropertyName=propertyValue1.

于 2017-09-28T08:39:08.293 回答