Search code examples
maventestngreportng

Using supported system properties without testng.xml


I want to use the system supported properties of ReportNG as specified here But I don't use testng.xml file to run test. Tests are executed by specifying the TestNG group on maven command line. I specified ReportNG system properties on pom.xml file as -

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-surefire-plugin</artifactId>
    <executions>
        <execution>
            <id>default-test</id>
            <goals>
                <goal>test</goal>
            </goals>
            <configuration>
                <argLine>-Xmx2048m -XX:MaxPermSize=512m</argLine>
                <properties>
                    <property>
                        <name>usedefaultlisteners</name>
                        <value>false</value>
                    </property>
                    <property>
                        <name>listener</name>
                        <value>org.uncommons.reportng.HTMLReporter, org.uncommons.reportng.JUnitXMLReporter</value>
                    </property>
                </properties>
                <systemProperties>
                    <systemProperty>
                        <name>org.uncommons.reportng.frames</name>
                        <value>false</value>
                    </systemProperty>
                    <systemProperty>
                        <name>org.uncommons.reportng.title</name>
                        <value>OBS Test Report</value>
                    </systemProperty>
                </systemProperties>
                <systemPropertyVariables>
                    <target.host>${target_host}</target.host>
                    <target.port>22</target.port>
                </systemPropertyVariables>
            </configuration>
        </execution>
    </executions>
</plugin>

But properties org.uncommons.reportng.frames and org.uncommons.reportng.title don't have any impact on generated reportng report. Where should I be specifying these properties?


Solution

  • I found a solution using pom.xml as following -

     <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-surefire-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>default-test</id>
                                <goals>
                                    <goal>test</goal>
                                </goals>
                                <configuration>
                                    <argLine>-Xmx2048m -XX:MaxPermSize=512m</argLine>
                                    <properties>
                                        <property>
                                            <name>listener</name>
                                            <value>org.uncommons.reportng.HTMLReporter, org.uncommons.reportng.JUnitXMLReporter</value>
                                        </property>
                                    </properties>
                                    <systemPropertyVariables>
                                        <org.uncommons.reportng.title>OBS Test Suite</org.uncommons.reportng.title>
                                        <org.uncommons.reportng.escape-output>false</org.uncommons.reportng.escape-output>
                                    </systemPropertyVariables>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>