Quantum test duplicator - Beta
Learn how you can simplify the process of executing the same TestNG XML test more than once but with a different set of capabilities or groups.
The duplicator takes the suite XML of the TestNG.xml
file and consumes it as is, without modification. Then, the duplicator consumes all test XML from the TestNG.xml
file. When a reference to a parameter called csvParams
is found, it duplicates the test XML. When the test is duplicated, all existing parameters in the test XML are considered, and the parameters from the CSV file are added on top or, in the case of duplication, the CSV will trump the test XML. If the test XML does not have a reference to the csvParams
parameter, it is left alone.
CSV format
Headers take any capability that you would normally add, such as perfecto.capability.model
. Those capabilities are consumed into the final test XML when the duplication occurs. Make sure that capabilities are typed explicitly the way you would add them to the testNg.xml
file. In addition to capabilities, you can add custom headers, such as includedGroups
or excludedGroups
.
As two headers suggest, you can add a comma-delimited string of groups to either include groups in or exclude groups from the test XML.
Input and output example
Each line of the CSV file duplicates the test XML. Therefore, given the examples provided in the (
and testng_web.xml
testParams.csv
), the original testNg.xml
looks as follows.
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="Web Demo Suite" verbose="0" parallel="tests"
thread-count="2">
<listeners>
<listener class-name="com.quantum.listeners.QuantumReportiumListener" />
<listener class-name="com.quantum.listeners.SuiteAlterer" />
</listeners>
<test name="Web Scenarios Test With Param" enabled="true">
<parameter name="csvParams" value="src/main/resources/data/testParams.csv"></parameter>
<groups>
<run>
<include name="regression" />
</run>
</groups>
<classes>
<class
name="com.quantum.steps.Tests" />
</classes>
</test>
</suite>
When ran through the Duplicator, the file would look as follows. As you can see, the single test is now two tests.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite thread-count="2" guice-stage="DEVELOPMENT" verbose="0" name="Web Demo Suite" parallel="tests">
<listeners>
<listener class-name="com.quantum.listeners.QuantumReportiumListener"/>
</listeners>
<test verbose="0" name="Web Scenarios Test With Param : 1" parallel="tests">
<parameter name="csvParams" value="src/main/resources/data/testParams.csv"/>
<parameter name="perfecto.capabilities.report.tags" value="blehan,blehan2"/>
<parameter name="env.resources" value="src/main/resources/android"/>
<parameter name="driver.capabilities.model" value="Galaxy.*"/>
<groups>
<run>
<include name="regression"/>
<include name="@AppleAn"/>
<include name="@JacksAn"/>
<exclude name="@UnicornAn"/>
<exclude name="@MuffinsAn"/>
</run>
</groups>
<classes>
<class name="com.quantum.steps.Tests"/>
</classes>
</test> <!-- Web Scenarios Test With Param : 1 -->
<test verbose="0" name="Web Scenarios Test With Param : 2" parallel="tests">
<parameter name="csvParams" value="src/main/resources/data/testParams.csv"/>
<parameter name="perfecto.capabilities.report.tags" value="blehio,blehio2"/>
<parameter name="env.resources" value="src/main/resources/iOS"/>
<parameter name="driver.capabilities.model" value="iPhone.*"/>
<groups>
<run>
<include name="regression"/>
<include name="@AppleIo"/>
<include name="@JacksIo"/>
<exclude name="@UnicornAn"/>
<exclude name="@MuffinsAn"/>
</run>
</groups>
<classes>
<class name="com.quantum.steps.Tests"/>
</classes>
</test> <!-- Web Scenarios Test With Param : 2 -->
</suite> <!-- Web Demo Suite -->
Run the Quantum test duplicator
To duplicate a Quantum test:
- Add the
SuiteAlterer
class to your project and update the package reference to clear any exceptions. As an example, see the attached fileSuiteAlterer.java
. -
Register the
SuiteAlterer
class to your existingtestNg.xml
file in the listeners section, as found in the exampletestng_web.xml
.Copy<listeners>
<listener class-name="com.quantum.listeners.QuantumReportiumListener" />
<listener class-name="com.quantum.listeners.SuiteAlterer" />
</listeners> -
Add a parameter named
csvParams
to your test XML section of yourtestNg.xml
file, as follows.Copy<test name="Web Scenarios Test With Param" enabled="true">
<parameter name="csvParams" value="src/main/resources/data/testParams.csv"></parameter> -
Create a CSV file similar to
testParams.csv
.