Search code examples
tychotycho-surefire-plugin

Adding Information To JUnit Test Results via tycho-surefire-plugin


The test results of JUnit tests have a properties tag with a bunch of properties. What is logged seems to be at the discretion of each executor of the tests.

I want to process the XML files further, so it would be really nice to have the same keys each time. For maven-surefire-plugin that's pretty straightforward:

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

This adds the line <property name="propertyName" value="propertyValue1"/> to the XML result file.

For the tycho-surefire-plugin, I tried the following:

<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>

...but neither of these values is printed inside the XML result.

How do I add information to the JUnit test results using tycho-surefire-plugin?


Solution

  • The documentation of the tycho-surefire-plugin states that you should use the <systemProperties> map:

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

    This will start the forked test JVM with -DpropertyName=propertyValue1.