Search code examples
seleniumselenium-webdrivercucumbertestngcucumber-jvm

How to generate TestNG runner file using cucumber-jvm-parallel-plugin?


Below is my POM file. I am unable to generate TestNG runner file while all the configs are correct. Please help me to do the correct configuration.

<build>
    <pluginManagement>
        <plugins>

            <plugin>
                <groupId>com.github.temyers</groupId>
                <artifactId>cucumber-jvm-parallel-plugin</artifactId>
                <version>4.2.0</version>
                <executions>
                    <execution>
                        <id>generateRunners</id>
                        <phase>generate-test-sources</phase>
                        <goals>
                            <goal>generateRunners</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>runner</outputDirectory>
                            <glue>
                                <package>com.compareglobalgroup.stepdefs</package>
                                <package>com.compareglobalgroup.cucumber.hooks</package>
                            </glue>
                            <featuresDirectory>src/test/resources/feature</featuresDirectory>
                            <cucumberOutputDir>target/cucumber-parallel</cucumberOutputDir>
                            <format>json</format>
                            <plugins>
                                <plugin>
                                    <name>json</name>
                                </plugin>
                            </plugins>
                            <tags>
                                <tag>@BBDK</tag>
                            </tags>
                            <useTestNG>true</useTestNG>
                            <!-- <namingScheme>simple</namingScheme> <namingPattern>Parallel{c}TestRunner</namingPattern> -->
                            <parallelScheme>FEATURE</parallelScheme>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.7.0</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.20.1</version>
                <configuration>
                    <forkCount>10</forkCount>
                    <reuseForks>true</reuseForks>
                    <includes>
                        <include>**/Parallel*IT.class</include>
                    </includes>
                    <!-- You can specify a specific testng.xml file here <suiteXmlFiles> 
                        <suiteXmlFile>src/test/resources/testng-sample.xml</suiteXmlFile> </suiteXmlFiles> -->
                    <!-- Or dynamically with something like '-DsuiteXmlFile=src/test/resources/testng-sample.xml' -->
                    <!-- <suiteXmlFiles> <suiteXmlFile>${suiteXmlFile}</suiteXmlFile> </suiteXmlFiles> -->
                    <!-- Build with '-DskipTests=true' to bypass test execution @ build 
                        time Default: false -->
                    <skipTests>false</skipTests>
                    <testFailureIgnore>true</testFailureIgnore>
                    <systemPropertyVariables>
                        <browser>${browser}</browser>
                        <execution>${execution}</execution>
                        <environment>${environment}</environment>
                        <!-- <suiteXmlFile>${suiteXmlFile}</suiteXmlFile> -->
                        <country>${country}</country>
                        <vertical>${vertical}</vertical>
                        <homeUrl>${homeUrl}</homeUrl>
                        <isHeadless>${isHeadless}</isHeadless>
                    </systemPropertyVariables>
                </configuration>
            </plugin>
        </plugins>
    </pluginManagement>
</build>

Solution

  • You need to have your <plugin> entry available under

    <build>
        <plugins>
            <plugin>
            <!-- add your plugin entry here -->
            </plugin>
        </plugins>
    </build>
    

    But you have added it under <pluginManagement> which is usually used to control plugin behavior for projects that inherit from the current one. See here for more information.