1
votes

Try to get separate json cucumber reports for each of two threads, but only got one report with combined execution time for both threads as it was not parallel run. Planned to run each thread on different device and after get report for each separate device. Is there any way to get its own json report for every thread?

Also tried: to use maven-surefire-plugin properties with threadcount but wasn't able even run parallel threads.

my pom.xml

<plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>3.0.0-M5</version>
            <configuration>
                <suiteXmlFiles>
                    <suiteXmlFile>parallelTests.xml</suiteXmlFile>
                </suiteXmlFiles>
            </configuration>
        </plugin>

runner

@CucumberOptions(
    plugin = {"pretty",
            "json:target/cucumber_report.json"},
    features = "features/",
    tags = "@test")
public class ParallelRun extends AbstractTestNGCucumberTests {
@Override
@DataProvider(parallel = true)
public Object[][] scenarios() {
    return super.scenarios();
}

testing xml

<suite name="Suite" parallel="tests" thread-count="2">
<test name="Thread 2">
    <classes>
        <class name="ParallelRun">
        </class>
    </classes>
</test>
<test name="Thread 1">
    <classes>
        <class name="ParallelRun">
        </class>
    </classes>
</test>

I was trying to get separate json reports with cucumber scenarios, steps, to combine them after with Multiple Cucumber HTML Reporter or other, but only get one json file with report for one thread

1
Surefire does not control this feature. Regarding multiple reports you have to ask the TestNG development group at github.com/cbeust/testngtibor17

1 Answers

0
votes

In order to to run the tests in parallel you need to create two separate runner classes, where the name of the reports should be different, to avoid overriding of report.json

Step 1: Create two separate TestRunner files with different .json file names

runner1:

@CucumberOptions(
    plugin = {"pretty",
            "json:target/cucumber_report1.json"},
    features = "features/",
    tags = "@test")
public class ParallelRun extends AbstractTestNGCucumberTests {
    @Override
    @DataProvider(parallel = true)
    public Object[][] scenarios() {
        return super.scenarios();
    }

runner2:

@CucumberOptions(
    plugin = {"pretty",
            "json:target/cucumber_report2.json"},
    features = "features/",
    tags = "@test")
public class ParallelRun extends AbstractTestNGCucumberTests {
    @Override
    @DataProvider(parallel = true)
    public Object[][] scenarios() {
        return super.scenarios();
    } 

Step 2: Update the xml file as below

testing xml:

<suite name="Suite" parallel="tests" thread-count="2">
<test name="Thread 2">
    <classes>
        <class name="runner1">
        </class>
    </classes>
</test>
<test name="Thread 1">
    <classes>
        <class name="runner2">
        </class>
    </classes>
</test>