0

I am trying to execute cucumber feature files in parallel by automatically generating test runners using cucumber-jvm plugin and running them parallel using maven-surefire plugin. When running the command "mvn clean test" i am getting the below errors

Below is my POM.xml, testng.xml file and testRunners.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="Suite" parallel="tests">   <!-- how many scenarios we can execute at a time is mentioned bt data-provider-thread-count-->
    <test name="ChromeTest" thread-count="5">
        <!--  <parameter name="browser" value="chrome"/>-->
        <classes>
        <class name="Parallel02IT"/>
        <class name="Parallel01IT"/>
        </classes>

    </test> <!-- Test -->

  <!--  <test name="new">
        <packages>
            <package name="target.generated-test-sources.cucumber.*"/>
            <package name="target.test-classes.*"/>
        </packages>
    </test>-->

</suite> <!-- Suite -->

Below is my POM.xml file

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.parallel</groupId>
    <artifactId>com.parallel.testng</artifactId>
    <version>1.0-SNAPSHOT</version>

    <build>
        <plugins>
            <plugin>
                <groupId>com.github.temyers</groupId>
                <artifactId>cucumber-jvm-parallel-plugin</artifactId>
                <version>2.1.0</version>
                <executions>
                    <execution>
                        <id>generateRunners</id>
                        <phase>generate-test-sources</phase>
                        <goals>
                            <goal>generateRunners</goal>
                        </goals>
                        <configuration>
                            <!-- Mandatory -->
                            <!-- comma separated list of package names to scan for glue code -->
                            <glue>stepdefinitions</glue>
                            <outputDirectory>${project.build.directory}/generated-test-sources/cucumber</outputDirectory>
                            <!-- The directory, which must be in the root of the runtime classpath, containing your feature files.  -->
                            <featuresDirectory>C:\Users\mbethu\IdeaProjects\comparalleltestng\src\main\input\features</featuresDirectory>
                            <!-- Directory where the cucumber report files shall be written  -->
                            <cucumberOutputDir>target/cucumber</cucumberOutputDir>
                            <!-- comma separated list of output formats json,html,rerun.txt -->
                            <format>html</format>
                            <!-- CucumberOptions.strict property -->
                            <strict>false</strict>
                            <!-- CucumberOptions.monochrome property -->
                            <monochrome>true</monochrome>
                            <!-- The tags to run, maps to CucumberOptions.tags property you can pass ANDed tags like "@tag1","@tag2" and ORed tags like "@tag1,@tag2,@tag3" -->
                            <!-- <tags></tags>-->
                            <!-- If set to true, only feature files containing the required tags shall be generated. -->
                            <filterFeaturesByTags>false</filterFeaturesByTags>
                            <!-- Generate TestNG runners instead of default JUnit ones. -->
                            <useTestNG>true</useTestNG>
                            <!-- The naming scheme to use for the generated test classes.  One of 'simple' or 'feature-title' -->
                            <namingScheme>simple</namingScheme>
                            <!-- The class naming pattern to use.  Only required/used if naming scheme is 'pattern'.-->
                            <namingPattern>Parallel{c}IT</namingPattern>
                            <!-- One of [SCENARIO, FEATURE]. SCENARIO generates one runner per scenario.  FEATURE generates a runner per feature. -->
                            <parallelScheme>FEATURE</parallelScheme>
                            <!-- This is optional, required only if you want to specify a custom template for the generated sources (this is a relative path) -->
                            <!--<customVmTemplate>src/test/resources/cucumber-custom-runner.vm</customVmTemplate>-->
                        </configuration>
                    </execution>
                </executions>
            </plugin>


            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.0</version>
                <configuration>
                    <fork>true</fork>
                    <executable>C:\Program Files\Java\jdk1.8.0_201\bin\javac.exe</executable>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.22.1</version>
                <configuration>
                    <!--<forkCount>5</forkCount>
                    <reuseForks>true</reuseForks>-->

                    <suiteXmlFiles>
                        <suiteXmlFile>src\main\resources\testng.xml</suiteXmlFile>
                    </suiteXmlFiles>

                    <testFailureIgnore>true</testFailureIgnore>
                    <parallel>classes</parallel>
                    <threadCount>10</threadCount>
                  <!--  <testErrorIgnore>true</testErrorIgnore>-->
                    <includes>
                        <include>src\test\java\testng.xml</include>
                        <!--<include>**/*IT.class</include>-->
                    </includes>
                </configuration>
            </plugin>
        </plugins>

    </build>


    <dependencies>
        <!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java -->
        <dependency>
            <groupId>org.seleniumhq.selenium</groupId>
            <artifactId>selenium-java</artifactId>
            <version>3.141.59</version>
        </dependency>

        <!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-server -->
        <dependency>
            <groupId>org.seleniumhq.selenium</groupId>
            <artifactId>selenium-server</artifactId>
            <version>3.141.59</version>
        </dependency>

        <!-- https://mvnrepository.com/artifact/io.cucumber/gherkin -->
        <dependency>
            <groupId>io.cucumber</groupId>
            <artifactId>gherkin</artifactId>
            <version>3.2.0</version>
        </dependency>

        <!-- https://mvnrepository.com/artifact/io.cucumber/cucumber-jvm -->
        <dependency>
            <groupId>io.cucumber</groupId>
            <artifactId>cucumber-jvm</artifactId>
            <version>4.3.0</version>
            <type>pom</type>
        </dependency>


        <!-- https://mvnrepository.com/artifact/org.testng/testng -->
        <dependency>
            <groupId>org.testng</groupId>
            <artifactId>testng</artifactId>
            <version>6.14.3</version>
            <scope>compile</scope>
        </dependency>


        <!-- https://mvnrepository.com/artifact/org.apache.maven.surefire/surefire-testng -->
        <!--    <dependency>
             <groupId>org.apache.maven.surefire</groupId>
             <artifactId>surefire-testng</artifactId>
             <version>2.22.1</version>
         </dependency>-->

        <!-- https://mvnrepository.com/artifact/info.cukes/cucumber-testng -->
        <!-- <dependency>
          <groupId>info.cukes</groupId>
          <artifactId>cucumber-testng</artifactId>
          <version>1.2.5</version>
      </dependency>-->
        <!-- https://mvnrepository.com/artifact/info.cukes/cucumber-java -->
        <!-- <dependency>
          <groupId>info.cukes</groupId>
          <artifactId>cucumber-java</artifactId>
          <version>1.2.5</version>
      </dependency>-->

        <!-- https://mvnrepository.com/artifact/info.cukes/cucumber-jvm -->
        <!--      <dependency>
               <groupId>info.cukes</groupId>
               <artifactId>cucumber-jvm</artifactId>
               <version>1.2.5</version>
               <type>pom</type>
           </dependency>-->

        <!-- https://mvnrepository.com/artifact/info.cukes/cucumber-jvm-deps -->
        <!--    <dependency>
            <groupId>info.cukes</groupId>
            <artifactId>cucumber-jvm-deps</artifactId>
            <version>1.0.5</version>
            <scope>provided</scope>
        </dependency>-->

        <!-- https://mvnrepository.com/artifact/info.cukes/gherkin -->
        <!--  <dependency>
              <groupId>info.cukes</groupId>
              <artifactId>gherkin</artifactId>
              <version>2.12.2</version>
              <scope>provided</scope>
          </dependency>
  -->
        <dependency>
            <groupId>io.cucumber</groupId>
            <artifactId>cucumber-java</artifactId>
            <version>4.2.3</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/io.cucumber/cucumber-testng -->
        <dependency>
            <groupId>io.cucumber</groupId>
            <artifactId>cucumber-testng</artifactId>
            <version>2.0.0</version>
        </dependency>

        <!-- https://mvnrepository.com/artifact/io.cucumber/cucumber-guice -->
        <dependency>
            <groupId>io.cucumber</groupId>
            <artifactId>cucumber-guice</artifactId>
            <version>4.3.0</version>
        </dependency>

        <dependency>
            <groupId>io.cucumber</groupId>
            <artifactId>cucumber-junit</artifactId>
            <version>4.2.3</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.12</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>io.cucumber</groupId>
            <artifactId>datatable</artifactId>
            <version>1.1.12</version>
        </dependency>

        <!-- https://mvnrepository.com/artifact/io.cucumber/cucumber-core -->
        <dependency>
            <groupId>io.cucumber</groupId>
            <artifactId>cucumber-core</artifactId>
            <version>4.3.0</version>
        </dependency>

        <dependency>
            <groupId>io.cucumber</groupId>
            <artifactId>cucumber-picocontainer</artifactId>
            <version>4.2.3</version>
            <scope>test</scope>
        </dependency>

    </dependencies>
</project>


Below are automatically generated testRunners
import cucumber.api.CucumberOptions;
import cucumber.api.testng.AbstractTestNGCucumberTests;

@CucumberOptions(strict = false,
features = {"C:/Users/mbethu/IdeaProjects/comparalleltestng/src/main/input/features/HomePage.feature"},
plugin = {"html:target/cucumber/1.html"},
monochrome = true,
tags = {},
glue = { "stepdefinitions" })
public class Parallel01IT extends AbstractTestNGCucumberTests {
}

[INFO] Scanning for projects... [INFO] [INFO] ------------------< com.parallel:com.parallel.testng >------------------ [INFO] Building com.parallel.testng 1.0-SNAPSHOT [INFO] --------------------------------[ jar ]--------------------------------- [INFO] [INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ com.parallel.testng --- [INFO] [INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ com.parallel.testng --- [WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent! [INFO] Copying 1 resource [INFO] [INFO] --- maven-compiler-plugin:3.0:compile (default-compile) @ com.parallel.testng --- [INFO] No sources to compile [INFO] [INFO] --- cucumber-jvm-parallel-plugin:2.1.0:generateRunners (generateRunners) @ com.parallel.testng --- [INFO] Adding C:\Users\mbethu\IdeaProjects\comparalleltestng\target\generated-test-sources\cucumber to test-compile source root [INFO] [INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ com.parallel.testng --- [WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent! [INFO] skip non existing resourceDirectory C:\Users\mbethu\IdeaProjects\comparalleltestng\src\test\resources [INFO] [INFO] --- maven-compiler-plugin:3.0:testCompile (default-testCompile) @ com.parallel.testng --- [INFO] Changes detected - recompiling the module! [WARNING] File encoding has not been set, using platform encoding Cp1252, i.e. build is platform dependent! [INFO] Compiling 2 source files to C:\Users\mbethu\IdeaProjects\comparalleltestng\target\test-classes [INFO] [INFO] --- maven-surefire-plugin:2.22.1:test (default-test) @ com.parallel.testng --- [INFO] [INFO] ------------------------------------------------------- [INFO] T E S T S [INFO] ------------------------------------------------------- [INFO] Running TestSuite [Utils] [ERROR] [Error] java.lang.NullPointerException at cucumber.api.testng.AbstractTestNGCucumberTests.scenarios(AbstractTestNGCucumberTests.java:31) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:124) at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:74) at org.testng.internal.MethodInvocationHelper.invokeMethodNoCheckedException(MethodInvocationHelper.java:45) at org.testng.internal.MethodInvocationHelper.invokeDataProvider(MethodInvocationHelper.java:131) at org.testng.internal.Parameters.handleParameters(Parameters.java:706) at org.testng.internal.ParameterHandler.handleParameters(ParameterHandler.java:49) at org.testng.internal.ParameterHandler.createParameters(ParameterHandler.java:37) at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:924) at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:125) at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:109) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang.Thread.run(Thread.java:748)

[Utils] [ERROR] [Error] java.lang.NullPointerException at cucumber.api.testng.AbstractTestNGCucumberTests.scenarios(AbstractTestNGCucumberTests.java:31) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:124) at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:74) at org.testng.internal.MethodInvocationHelper.invokeMethodNoCheckedException(MethodInvocationHelper.java:45) at org.testng.internal.MethodInvocationHelper.invokeDataProvider(MethodInvocationHelper.java:131) at org.testng.internal.Parameters.handleParameters(Parameters.java:706) at org.testng.internal.ParameterHandler.handleParameters(ParameterHandler.java:49) at org.testng.internal.ParameterHandler.createParameters(ParameterHandler.java:37) at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:924) at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:125) at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:109) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang.Thread.run(Thread.java:748)

[ERROR] Tests run: 6, Failures: 4, Errors: 0, Skipped: 2, Time elapsed: 0.767 s <<< FAILURE! - in TestSuite [ERROR] setUpClass(Parallel01IT) Time elapsed: 0.51 s <<< FAILURE! java.lang.NoSuchMethodError: cucumber.runtime.Runtime.(Lcucumber/runtime/io/ResourceLoader;Lcucumber/runtime/ClassFinder;Ljava/lang/ClassLoader;Lcucumber/runtime/RuntimeOptions;)V

[ERROR] setUpClass(Parallel02IT) Time elapsed: 0.511 s <<< FAILURE! java.lang.NoSuchMethodError: cucumber.runtime.Runtime.(Lcucumber/runtime/io/ResourceLoader;Lcucumber/runtime/ClassFinder;Ljava/lang/ClassLoader;Lcucumber/runtime/RuntimeOptions;)V

[ERROR] tearDownClass(Parallel01IT) Time elapsed: 0.766 s <<< FAILURE! java.lang.NullPointerException

[ERROR] tearDownClass(Parallel02IT) Time elapsed: 0.766 s <<< FAILURE! java.lang.NullPointerException

[INFO] [INFO] Results: [INFO] [ERROR] Failures: [ERROR]
Parallel01IT>AbstractTestNGCucumberTests.setUpClass:16 » NoSuchMethod cucumber... [ERROR]
Parallel01IT>AbstractTestNGCucumberTests.tearDownClass:36 » NullPointer [ERROR]
Parallel02IT>AbstractTestNGCucumberTests.setUpClass:16 » NoSuchMethod cucumber... [ERROR]
Parallel02IT>AbstractTestNGCucumberTests.tearDownClass:36 » NullPointer [INFO] [ERROR] Tests run: 6, Failures: 4, Errors: 0, Skipped: 2 [INFO] [ERROR] There are test failures.

Please refer to C:\Users\mbethu\IdeaProjects\comparalleltestng\target\surefire-reports for the individual test results. Please refer to dump files (if any exist) [date].dump, [date]-jvmRun[N].dump and [date].dumpstream. [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 5.143 s [INFO] Finished at:

2019-04-22T23:12:30+05:30 [INFO]

1 Answer 1

1

On https://github.com/temyers/cucumber-jvm-parallel-plugin you can find

As of cucumber-jvm:4.0.0 parallel execution is supported natively by cucumber. As such, upgrading to Cucumber 4.0.0 is recommended and this plugin is no longer maintained.

Note that latest version is 4.3.0 https://mvnrepository.com/artifact/io.cucumber/cucumber-testng/4.3.0 You have multiple different versions in your pom file - please unify. Generally your pom file is quite messy. All you need is probably:

    <!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-server -->
    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-server</artifactId>
        <version>3.141.59</version>
    </dependency>

    <!-- https://mvnrepository.com/artifact/io.cucumber/cucumber-java -->
    <dependency>
        <groupId>io.cucumber</groupId>
        <artifactId>cucumber-java</artifactId>
        <version>4.3.0</version>
    </dependency>

    <!-- https://mvnrepository.com/artifact/io.cucumber/cucumber-testng -->
    <dependency>
        <groupId>io.cucumber</groupId>
        <artifactId>cucumber-testng</artifactId>
        <version>4.3.0</version>
    </dependency>

For parallel execution check https://github.com/cucumber/cucumber-jvm/blob/master/testng/README.md#parallel-execution

Sign up to request clarification or add additional context in comments.

4 Comments

i have updated cucumber to latest version.I want to generate testRunners automatically, apart from cucumber-jvm-parallel plugin is there any other plugin to generate testRunners automatically.
May i know apart from cucumber jvm parallel plugin what else can i use to generate TestRunners automatically
Unfortunately I don't know, I do what I describe above and run mvn test. Sorry
That's fine, Thank you .. @lojza

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.