Skip to content
This repository has been archived by the owner on Mar 18, 2019. It is now read-only.

How do we rerun failed scenarios #31

Closed
saikrishna321 opened this issue May 10, 2016 · 42 comments
Closed

How do we rerun failed scenarios #31

saikrishna321 opened this issue May 10, 2016 · 42 comments

Comments

@saikrishna321
Copy link
Contributor

@temyers is there a way we can re-run failed scenarios?

@temyers
Copy link
Owner

temyers commented May 10, 2016

I'd really consider this outside the scope of the parallel plugin. Isn't that more down to the execution mechanism?

@saikrishna321
Copy link
Contributor Author

@temyers there is a mechanism at the cucumber end. We need to generate the Runner this way

@RunWith(Cucumber.class)
@CucumberOptions(strict = true, glue = { "example.cucumber" }, 
features = { "src/test/features" }, 
plugin = { "json:target/cucumber-report-composite.json", "pretty",
        "html:target/cucumber/","rerun:target/rerun_featureName.txt" }, 
tags = { "~@skip" })
public class TestExampleCucumberIT {

}

true

2

And then if a Failures is present then a new Runner class should be as

@RunWith(Cucumber.class)
@CucumberOptions(strict = true, 
glue = { "example.cucumber" }, 
features = { "@target/rerun.txt" }, 
plugin = { "json:target/cucumber-report-composite.json", "pretty",
        "html:target/cucumber/"})
public class _TestExampleCucumberIT {
}

cucumber/cucumber-jvm#890

@Balhindi
Copy link

@saikrishna321
Copy link
Contributor Author

How does this work in rerunning the cucumber features ?

@Balhindi
Copy link

Balhindi commented May 14, 2016

Sorry I meant to say it reruns failed Features, so when one scenario fails in one of the features, it will rerun the entire feature with all the scenarios even if some of the scenarios passed (I am trying to figure out a way to make it work where it only runs the failed scenario instead of the entire feature).

So if you are running your features through an XML file from TestNG and if you setup it up something like this.

?xml version="1.0" encoding="UTF-8"?
DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd
suite name="run tests in parallel" verbose="1" configfailurepolicy="continue" thread-count="1
parameter name="xx" value="xxx"
listeners
listener class-name="com.helloworld.LocalWebDriverListener" /
listener class-name="com.helloworld.RetryListener" /
/listeners
test name="Tests in Chrome"
parameter name="browserName" value="chrome" /
classes
class name="com.helloworld.runners.RunCukesTestInChrome"/
/classes
/test
/suite>

first the RetryListener will check if the retry is needed by checking in with RepeatTestListner (It will be null at first, then it will return true when something fails)The TestNG getResultStatusName(result.getStatus()) function in RepeatTestListner will read the status and see what the status is. if the status is 2 then the feature has failed of course. That it will rerun it once, or how many times you want it reran. This will only work if you run your cucumber test from the TestNG XML file or through a Maven configuration. IT will not work if you are running though the runner directly or if you are running the feature directly. The only way it could maybe work with the cucumber-jvm-parallel-plugin I think is through Maven, because the TestNG XML file needs a specific runner (Although I am not too sure, and have not yet tried it, I will let you know if it works later on). (It is not perfect, but I am trying to find a way to make it work a little better).

public class RepeatTestListner implements IRetryAnalyzer {
{
private int retryCount = 0;
private int maxRetryCount = 1;

public boolean retry(ITestResult result) {
log.info("BEGINNING: retry");
if (retryCount < maxRetryCount) {
System.out.println("Retrying test " + result.getName() + " with status "
+ getResultStatusName(result.getStatus()) + " for the " + (retryCount + 1) + " time(s).");
retryCount++;
return true;
}
return false;
}

public String getResultStatusName(int status) {
log.info("Status of this is" + status);
String resultName = null;
if (status == 1)
resultName = "SUCCESS";
if (status == 2)
resultName = "FAILURE";
if (status == 3)
resultName = "SKIP";
return resultName;
}
}

public class RetryListener implements IAnnotationTransformer
{

static Logger log = Logger.getLogger(RetryListener.class);

@Override
public void transform(ITestAnnotation testannotation, Class testClass,
                      Constructor testConstructor, Method testMethod)   
   {
    log.info("Checking if a retry is needed");
    IRetryAnalyzer retry = testannotation.getRetryAnalyzer();

    if (retry == null)  
    {
        testannotation.setRetryAnalyzer(RepeatTestListner.class);
    }

    }

}

@Balhindi
Copy link

@temyers I would also really love to see this feature added, I can try to help and make it possible. We can inject the "rerun:target/rerun.txt" (or wherever you want to failed scenarios to go) in all of the runners in the plugins section, then automatically create an extra runners with the _ at the start of it. and have the runner run like Sai said with features = { "@target/rerun.txt" }. I can for see the issue of many runners and trying to figure out which runners should run on which device if running parallel devices. Let me know thank you.

TestExampleCucumberIT.java: test runner that will perform the first test execution and record data in target/rerun.txt

package example.cucumber;

import org.junit.runner.RunWith;

import cucumber.api.CucumberOptions;

import cucumber.api.junit.Cucumber;
@RunWith(Cucumber.class)
@CucumberOptions(strict = true, glue = { "example.cucumber" },
features = { "src/test/features" },
plugin = { "json:target/cucumber-report-composite.json", "pretty",
"html:target/cucumber/","rerun:target/rerun.txt" },
tags = { "~@Skip" })
public class TestExampleCucumberIT {

}

the _TestExampleCucumberIT.java will perform the second test execution (as maven will run all IT class, the second one start with _ so it will be run after the previous test bulk)

package example.cucumber;

import org.junit.runner.RunWith;

import cucumber.api.CucumberOptions;

import cucumber.api.junit.Cucumber;
@RunWith(Cucumber.class)
@CucumberOptions(strict = true,
glue = { "example.cucumber" },
features = { "@target/rerun.txt" },
plugin = { "json:target/cucumber-report-composite.json", "pretty",
"html:target/cucumber/"})
public class _TestExampleCucumberIT {
}

@sugatmankar
Copy link
Contributor

Hello temyers,
I have developed custom re runner velocity template and used it same way as you did. Please check forked repo https://github.com/sugatmankar/cucumber-jvm-parallel-plugin . It is easy to capture failed test scenarios in rerun file but to re run all those with parallel it was big challenge for me so i did it with older cucumber api. I have to create ExtendedRuntime Option class just to comment out reading environment variable again n again While reruns using maven with -Dcucumber.option.
Please have look at repository.

@temyers
Copy link
Owner

temyers commented May 19, 2016

Thinking about this more, I'm actually not sure if it's a desirable feature since it is pointing to an underlying issue with the tests - they are flaky. If you re-run an automated test without making changes, you should really get the same results.

Flaky tests are an anti-pattern:

@saikrishna321
Copy link
Contributor Author

@temyers i feel this a needed feature, let me explain i run my tests on real devices android and iOS at times the server time-out / network issues and at times i have seen USB releasing the devices and replugging and lot more...

These tests are not functional failure tests just the env problem, rerunning them would help..

The links which you have mentioned above all talks on website functional tests, but mobile tests are very much different from that ..
Thoughts ??

@temyers
Copy link
Owner

temyers commented May 25, 2016

They were in relation to web apps, but i think it's still valid for mobile development.

Things like server time-outs, etc are real issues that need to be considered when testing and developing the app. For example, adding in appropriate waits etc. Shouldn't the application be able to better handle such environmental changes which are natural on a mobile device?

If you've got flaky tests, doesn't that suggest that there is something missing in the setup/interactions?

@saikrishna321
Copy link
Contributor Author

@temyers i agree.. But when i have drop in network i need to retest the functionality

@JasonSmiley208
Copy link
Contributor

JasonSmiley208 commented May 25, 2016

Just an FYI, maven surefire plugin knows about failing tests as well. However, the maven surefire plugin does not know how to use a cucumber feature file, so we need to use the cucumber solution (in my opinion). Not sure how to configure the junit surefire plugin to use the Cucumber.class file instead of the default JUnit one.

@temyers
Copy link
Owner

temyers commented May 25, 2016

I'm going to add this in with pr #30.

@ghost
Copy link

ghost commented Nov 19, 2016

It's a big mistake to accept flaky tests, just ask Facebook. A better approach is to build the required resiliency in to the application and determine transient issues and act accordingly.

In Spring, see Spring-retry.

If using Java you can introduce your own annotation like this library has:
https://github.com/petergeneric/stdlib/blob/7afc63ae37ad49ebe815a35d823c85923c5c398b/guice/common/src/main/java/com/peterphi/std/guice/common/retry/retry/Retryable.java

@sugatmankar
Copy link
Contributor

Re-implemented in PR #89.

@kevbradwick
Copy link

I would just like to add a use case to support this feature...

I'd like to run a selection of scenario's that cannot be grouped by tags. The only way to do this is produce a file in the rerun format. Using this technique, I can then build a parameterised build on Jenkins to accept these files to run them on an ad-hoc basis.

@mpkorstanje
Copy link
Collaborator

This plug in only creates the tests. It does not execute them. Running tests and rerunning failing tests is a build-in feature of surefire and failsafe. You should use these.

https://maven.apache.org/surefire/maven-failsafe-plugin/examples/rerun-failing-tests.html
https://maven.apache.org/surefire/maven-surefire-plugin/examples/rerun-failing-tests.html

@rakeshnambiar
Copy link

rakeshnambiar commented May 10, 2017

Does anyone try it out for Tag level? Pls let me know

@mpkorstanje
Copy link
Collaborator

mpkorstanje commented May 10, 2017

Mrph. It appears that using surefire rerun results in a stack trace. Seems to be caused by cucumber not using the runners class name. So that option is out unless some one fixes surefire.

cucumber/cucumber-jvm#1120

org.apache.maven.surefire.testset.TestSetFailedException: Unable to create test class 'Scenario: Fail when running'
        at org.apache.maven.surefire.junit4.JUnit4Provider.executeFailedMethod(JUnit4Provider.java:385)
        at org.apache.maven.surefire.junit4.JUnit4Provider.executeWithRerun(JUnit4Provider.java:292)
        at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:238)
        at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:161)
Caused by: java.lang.ClassNotFoundException: Scenario: Fail when running
        at org.apache.maven.surefire.junit4.JUnit4Provider.executeFailedMethod(JUnit4Provider.java:379)
        at org.apache.maven.surefire.junit4.JUnit4Provider.executeWithRerun(JUnit4Provider.java:292)
        at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:238)
        at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:161)

@mpkorstanje
Copy link
Collaborator

@temyers could you help out in reviewing cucumber/cucumber-jvm#1035? This appears to be the current blocker.

For context please see the Cukes mailing list. And perhaps @MagenTys might also be interested.

mpkorstanje added a commit to cucumber/cucumber-jvm that referenced this issue May 25, 2017
…e tests.

Surefire currently uses a tuple of (Class, Method) to identify failed tests.
Cucumber-jvm uses test suites which do not consist of Classes or methods.
Therefore another method is needed.

JUnit provides the option to select tests that match a Description.
Descriptions are compared using  a unique Id. To identify tests between
different runs we should provide Descriptions with a predictable unique
id.

The current implementation did not suffice. While the provided cucumber
elements are unique, they are not predictable between runs making it
impossible to use their descriptions to rerun a failed test.

After this change it will be possible to update Surefire to use
descriptions to rerun failed tests.

  Related Issues:
  - https://issues.apache.org/jira/browse/SUREFIRE-1372
  - #1120
  - temyers/cucumber-jvm-parallel-plugin#31

(cherry picked from commit 4cc4439)
mpkorstanje added a commit to cucumber/cucumber-jvm that referenced this issue May 25, 2017
Rerunning failed tests with Surefire requires a method to identify the tests.
Surefire currently uses a tuple of (Class, Method) to identify failed tests.
Cucumber-jvm uses test suites which do not consist of Classes or methods.
Therefore another method is needed.

JUnit provides the option to select tests that match a Description.
Descriptions are compared using an unique Id. To identify tests between
different runs we should provide Descriptions with a predictable unique
id.

The current implementation did not suffice. While the provided cucumber
elements are unique, they are not predictable. Each run would create a new
instance of the identifier making it impossible to use their descriptions
to rerun a failed test.

After this change it will be possible to update Surefire to use
descriptions to rerun failed tests.

  Related Issues:
  - https://issues.apache.org/jira/browse/SUREFIRE-1372
  - #1120
  - temyers/cucumber-jvm-parallel-plugin#31
mpkorstanje added a commit to cucumber/cucumber-jvm that referenced this issue May 26, 2017
Rerunning failed tests with Surefire requires a method to identify the tests.
Surefire currently uses a tuple of (Class, Method) to identify failed tests.
Cucumber-jvm uses test suites which do not consist of Classes or methods.
Therefore another method is needed.

JUnit provides the option to select tests that match a Description.
Descriptions are compared using an unique Id. To identify tests between
different runs we should provide Descriptions with a predictable unique
id.

The current implementation did not suffice. While the provided cucumber
elements are unique, they are not predictable. Each run would create a new
instance of the identifier making it impossible to use their descriptions
to rerun a failed test.

After this change it will be possible to update Surefire to use
descriptions to rerun failed tests.

  Related Issues:
  - https://issues.apache.org/jira/browse/SUREFIRE-1372
  - #1120
  - temyers/cucumber-jvm-parallel-plugin#31
mpkorstanje added a commit to cucumber/cucumber-jvm that referenced this issue May 26, 2017
Rerunning failed tests with Surefire requires a method to identify the tests.
Surefire currently uses a tuple of (Class, Method) to identify failed tests.
Cucumber-jvm uses test suites which do not consist of Classes or methods.
Therefore another method is needed.

JUnit provides the option to select tests that match a Description.
Descriptions are compared using an unique Id. To identify tests between
different runs we should provide Descriptions with a predictable unique
id.

The current implementation did not suffice. While the provided cucumber
elements are unique, they are not predictable. Each run would create a new
instance of the identifier making it impossible to use their descriptions
to rerun a failed test.

After this change it will be possible to update Surefire to use
descriptions to rerun failed tests.

  Related Issues:
  - https://issues.apache.org/jira/browse/SUREFIRE-1372
  - #1120
  - temyers/cucumber-jvm-parallel-plugin#31
asfgit pushed a commit to apache/maven-surefire that referenced this issue Jan 4, 2018
Description#createSuiteDescription

 Filtering tests by the tuple of (Class, Method) does not work when a test
 suite is used as a suite may not have (Class, Method) . Filtering by the
 description of the failed test should however work.

 Related Issues:
 - cucumber/cucumber-jvm#1134
 - temyers/cucumber-jvm-parallel-plugin#31

SUREFIRE-1372 Filter junit4 tests to be rerun by description
@lineshvr
Copy link

lineshvr commented Jan 4, 2018

Anyone is working on "rerun" failed scenario , I have found few old links which have mentioned about "rerun" https://github.com/sugatmankar/cucumber-jvm-parallel-plugin-rerun-example
But those are very old. I have tried many options but no luck.

@mpkorstanje
Copy link
Collaborator

image

@Shareef112
Copy link

Hi Team, Surefire-1372 fixed and released so Can we use Rerun functionality in tymers cucumber parallel plug in to rerun failed cases.

@mpkorstanje
Copy link
Collaborator

Haven't had a chance to test it yet!

@Shareef112
Copy link

Shareef112 commented Mar 21, 2018

I tested with providing Surefire version 2.21.0 and temyers cucumber parallel plugin 4.2.0. while running the POM it is failing saying Forked VM is crashed. I am able to run by using Surefire 2.20. Please refer below Configuration and Error Message.
Configuration:

com.github.temyers cucumber-jvm-parallel-plugin 4.2.0 generateRunners validate generateRunners com.clinical
                        <!-- These are the default values -->
                        <!-- Where to output the generated Junit tests -->
                        <outputDirectory>${project.build.directory}/generated-test-sources/cucumber</outputDirectory>
                        <!-- The diectory containing your feature files. -->
                        <featuresDirectory>src/test/resources/features/</featuresDirectory>
                        <!-- Directory where the cucumber report files shall be written -->
                        <cucumberOutputDir>target/cucumber-parallel</cucumberOutputDir>
                        <!-- comma separated list of output formats -->
                        <format>json</format>
                        <!-- CucumberOptions.strict property -->
                        <strict>true</strict>
                        <!-- CucumberOptions.monochrome property -->
                        <monochrome>true</monochrome>
                        <!-- The tags to run, maps to CucumberOptions.tags property -->
                        <tags>
                            <tag>${tagToRun}</tag>
                        </tags>
                        <!-- If set to true, only feature files containing the required tags
                                shall be generated. -->
                        <!-- Generate TestNG runners instead of 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>
                        <parallelScheme>SCENARIO</parallelScheme>
                    </configuration>
                </execution>
            </executions>
        </plugin>

        <!--This plugin's configuration is used to Run the classes with name Parallel@@IT -->
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>2.21.0</version>
            <executions>
                <execution>
                    <id>acceptance-test</id>
                    <phase>integration-test</phase>
                    <goals>
                        <goal>test</goal>
                    </goals>
                    <configuration>
                        <systemPropertyVariables>
                            <Applicationurl>${Applicationurl}</Applicationurl>
                            <Environment>${Environment}</Environment>
                            <Browser>${Browser}</Browser>
                            <ICUEEnvironment>${ICUEEnvironment}</ICUEEnvironment>
                        </systemPropertyVariables>
                        <forkCount>1</forkCount>
                        <reuseForks>false</reuseForks>
                        <rerunFailingTestsCount>2</rerunFailingTestsCount>
                        <trimStackTrace>false</trimStackTrace>
                        <forkMode>once</forkMode>
                        <argLine>-Xmx1024m -XX:MaxPermSize=256m</argLine>
                        <includes>
                            <include>**/*IT.java</include>
                        </includes>
                    </configuration>
                </execution>
            </executions>
        </plugin>

error Message:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.21.0:test (acceptance-test) on project ClinicalAutomation: There are test failures.
[ERROR]
[ERROR] Please refer to C:\Users\mshaik21\Desktop\Rerun\TNMigration_TeamAnne\target\surefire-reports for the individual test results.
[ERROR] Please refer to dump files (if any exist) [date]-jvmRun[N].dump, [date].dumpstream and [date]-jvmRun[N].dumpstream.
[ERROR] ExecutionException The forked VM terminated without properly saying goodbye. VM crash or System.exit called?
[ERROR] Command was cmd.exe /X /C ""C:\Program Files (x86)\Java\jdk1.8.0_91\jre\bin\java" -Xmx1024m -XX:MaxPermSize=256m -jar C:\Users\mshaik21\AppData\Local\Temp\surefire8154131045878875901\surefirebooter477155787480945598.jar C:\Users\mshaik21\AppData\Local\Temp\surefire8154131045878875901 2018-03-21T15-13-30_818-jvmRun1 surefire8570323074213899854tmp surefire_16294149141290156222tmp"
[ERROR] Error occurred in starting fork, check output in log
[ERROR] Process Exit Code: 1
[ERROR] Crashed tests:
[ERROR] Parallel01IT
[ERROR] ExecutionException The forked VM terminated without properly saying goodbye. VM crash or System.exit called?
[ERROR] Command was cmd.exe /X /C ""C:\Program Files (x86)\Java\jdk1.8.0_91\jre\bin\java" -Xmx1024m -XX:MaxPermSize=256m -jar C:\Users\mshaik21\AppData\Local\Temp\surefire8154131045878875901\surefirebooter5628597083843223428.jar C:\Users\mshaik21\AppData\Local\Temp\surefire8154131045878875901 2018-03-21T15-13-30_818-jvmRun1 surefire6739741059332556584tmp surefire_22156427586551106900tmp"
[ERROR] Error occurred in starting fork, check output in log
[ERROR] Process Exit Code: 1
[ERROR] org.apache.maven.surefire.booter.SurefireBooterForkException: ExecutionException The forked VM terminated without properly saying goodbye. VM crash or System.exit called?
[ERROR] Command was cmd.exe /X /C ""C:\Program Files (x86)\Java\jdk1.8.0_91\jre\bin\java" -Xmx1024m -XX:MaxPermSize=256m -jar C:\Users\mshaik21\AppData\Local\Temp\surefire8154131045878875901\surefirebooter477155787480945598.jar C:\Users\mshaik21\AppData\Local\Temp\surefire8154131045878875901 2018-03-21T15-13-30_818-jvmRun1 surefire8570323074213899854tmp surefire_16294149141290156222tmp"
[ERROR] Error occurred in starting fork, check output in log
[ERROR] Process Exit Code: 1
[ERROR] Crashed tests:
[ERROR] Parallel01IT
[ERROR] ExecutionException The forked VM terminated without properly saying goodbye. VM crash or System.exit called?
[ERROR] Command was cmd.exe /X /C ""C:\Program Files (x86)\Java\jdk1.8.0_91\jre\bin\java" -Xmx1024m -XX:MaxPermSize=256m -jar C:\Users\mshaik21\AppData\Local\Temp\surefire8154131045878875901\surefirebooter5628597083843223428.jar C:\Users\mshaik21\AppData\Local\Temp\surefire8154131045878875901 2018-03-21T15-13-30_818-jvmRun1 surefire6739741059332556584tmp surefire_22156427586551106900tmp"
[ERROR] Error occurred in starting fork, check output in log
[ERROR] Process Exit Code: 1
[ERROR] at org.apache.maven.plugin.surefire.booterclient.ForkStarter.awaitResultsDone(ForkStarter.java:494)
[ERROR] at org.apache.maven.plugin.surefire.booterclient.ForkStarter.runSuitesForkPerTestSet(ForkStarter.java:441)
[ERROR] at org.apache.maven.plugin.surefire.booterclient.ForkStarter.run(ForkStarter.java:293)
[ERROR] at org.apache.maven.plugin.surefire.booterclient.ForkStarter.run(ForkStarter.java:245)
[ERROR] at org.apache.maven.plugin.surefire.AbstractSurefireMojo.executeProvider(AbstractSurefireMojo.java:1149)
[ERROR] at org.apache.maven.plugin.surefire.AbstractSurefireMojo.executeAfterPreconditionsChecked(AbstractSurefireMojo.java:978)
[ERROR] at org.apache.maven.plugin.surefire.AbstractSurefireMojo.execute(AbstractSurefireMojo.java:854)
[ERROR] at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
[ERROR] at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:207)
[ERROR] at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
[ERROR] at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
[ERROR] at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
[ERROR] at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
[ERROR] at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
[ERROR] at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
[ERROR] at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
[ERROR] at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
[ERROR] at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
[ERROR] at org.apache.maven.cli.MavenCli.execute(MavenCli.java:863)
[ERROR] at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288)
[ERROR] at org.apache.maven.cli.MavenCli.main(MavenCli.java:199)
[ERROR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[ERROR] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
[ERROR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[ERROR] at java.lang.reflect.Method.invoke(Method.java:498)
[ERROR] at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
[ERROR] at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
[ERROR] at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
[ERROR] at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
[ERROR] at org.codehaus.classworlds.Launcher.main(Launcher.java:47)
[ERROR] Caused by: org.apache.maven.surefire.booter.SurefireBooterForkException: The forked VM terminated without properly saying goodbye. VM crash or System.exit called?
[ERROR] Command was cmd.exe /X /C ""C:\Program Files (x86)\Java\jdk1.8.0_91\jre\bin\java" -Xmx1024m -XX:MaxPermSize=256m -jar C:\Users\mshaik21\AppData\Local\Temp\surefire8154131045878875901\surefirebooter5628597083843223428.jar C:\Users\mshaik21\AppData\Local\Temp\surefire8154131045878875901 2018-03-21T15-13-30_818-jvmRun1 surefire6739741059332556584tmp surefire_22156427586551106900tmp"
[ERROR] Error occurred in starting fork, check output in log
[ERROR] Process Exit Code: 1
[ERROR] at org.apache.maven.plugin.surefire.booterclient.ForkStarter.fork(ForkStarter.java:671)
[ERROR] at org.apache.maven.plugin.surefire.booterclient.ForkStarter.fork(ForkStarter.java:533)
[ERROR] at org.apache.maven.plugin.surefire.booterclient.ForkStarter.access$600(ForkStarter.java:115)
[ERROR] at org.apache.maven.plugin.surefire.booterclient.ForkStarter$2.call(ForkStarter.java:429)
[ERROR] at org.apache.maven.plugin.surefire.booterclient.ForkStarter$2.call(ForkStarter.java:406)
[ERROR] at java.util.concurrent.FutureTask.run(FutureTask.java:266)
[ERROR] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
[ERROR] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
[ERROR] at java.lang.Thread.run(Thread.java:745)
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

@mpkorstanje
Copy link
Collaborator

@Shareef112 I just had a chance to test it. I can't reproduce that particular problem. I'm afraid you'll have make an MVCE out of it.

This works as expected:

<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>

    <parent>
        <groupId>io.cucumber</groupId>
        <artifactId>cucumber-examples</artifactId>
        <version>3.0.0-SNAPSHOT</version>
    </parent>

    <artifactId>java-calculator</artifactId>
    <packaging>jar</packaging>
    <name>Examples: Java Calculator</name>

    <dependencies>
      ...
    </dependencies>

    <properties>
        <surefire.rerunFailingTestsCount>2</surefire.rerunFailingTestsCount>
    </properties>

    <build>
        <plugins>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.21.0</version>
            </plugin>
        ...
    </build>
</project>

Which for a flaky test will output:

[INFO] -------------------------------------------------------
[INFO]  T E S T S
[INFO] -------------------------------------------------------
[INFO] Running cucumber.examples.java.calculator.RunCukesTest
F--...........................Runs before scenarios *not* tagged with @foo...Runs before scenarios *not* tagged with @foo...

Failed scenarios:
cucumber/examples/java/calculator/basic_arithmetic.feature:7 # Addition

8 Scenarios (1 failed, 7 passed)
36 Steps (1 failed, 2 skipped, 33 passed)
0m0.051s

java.lang.Exception
        at cucumber.examples.java.calculator.RpnCalculatorStepdefs.a_calculator_I_just_turned_on(RpnCalculatorStepdefs.java:22)
        at ✽.a calculator I just turned on(cucumber/examples/java/calculator/basic_arithmetic.feature:5)

...

1 Scenarios (1 passed)
3 Steps (3 passed)
0m0.003s

[ERROR] Tests run: 9, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.237 s <<< FAILURE! - in cucumber.examples.java.calculator.RunCukesTest
[ERROR] Addition(Basic Arithmetic)  Time elapsed: 0.006 s  <<< ERROR!
java.lang.Exception

[INFO] 
[INFO] Results:
[INFO] 
[WARNING] Flakes: 
[WARNING] Basic Arithmetic.Addition(Basic Arithmetic)
[ERROR]   Run 1: null
[INFO]   Run 2: PASS
[INFO] 
[INFO] 
[WARNING] Tests run: 8, Failures: 0, Errors: 0, Skipped: 0, Flakes: 1
[INFO] 
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------

Also worth noting that the output from json formatter and other cucumber formatters will be overwritten with the latest results from the rerun. This shouldn't be a problem if you're parallelizing by scenario but will cause problems if you're parallelizing by feature (as I've done in this example). The surefire report however is still accurate.

@Shareef112
Copy link

@mpkorstanje can you plese provide me the dependencies which you are used.
I tried again I am still getting same error message.The pom which I am using

@mpkorstanje
Copy link
Collaborator

It's the cucumber-java-calculator example. The 3.0.0-SNAPSHOT verdion from the cucumber-jvm git. Rigged it with an intermittent failure. Latest 2.x should work too.

@mpkorstanje
Copy link
Collaborator

You could also use threads instead of forks. Or forbid them all together and see what kills the JVM.

@laddushashavali
Copy link

Hi Team ,
I am getting the below error while running the test using this plugin any help on the below issue is apprciated :

[INFO] Scanning for projects...
[WARNING]
[WARNING] Some problems were encountered while building the effective model for RMT_Regression:RMT_Regression:jar:1.0-SNAPSHOT
[WARNING] 'dependencies.dependency.(groupId:artifactId:type:classifier)' must be unique: info.cukes:cucumber-testng:jar -> version 1.1.5 vs 1.2.0 @ line 283, column 15
[WARNING] 'dependencies.dependency.(groupId:artifactId:type:classifier)' must be unique: com.google.code.gson:gson:jar -> duplicate declaration of version 2.3.1 @ line 311, column 15
[WARNING] 'dependencies.dependency.(groupId:artifactId:type:classifier)' must be unique: log4j:log4j:jar -> duplicate declaration of version 1.2.17 @ line 316, column 15
[WARNING] 'dependencies.dependency.(groupId:artifactId:type:classifier)' must be unique: com.googlecode.json-simple:json-simple:jar -> duplicate declaration of version 1.1.1 @ line 331, column 15
[WARNING] 'dependencies.dependency.(groupId:artifactId:type:classifier)' must be unique: info.cukes:cucumber-junit:jar -> version ${cucumber.version} vs 1.2.2 @ line 336, column 15
[WARNING] 'dependencies.dependency.(groupId:artifactId:type:classifier)' must be unique: info.cukes:cucumber-testng:jar -> version 1.1.5 vs 1.2.0 @ line 341, column 15
[WARNING] 'dependencies.dependency.(groupId:artifactId:type:classifier)' must be unique: junit:junit:jar -> version ${junit.version} vs 4.12 @ line 346, column 15
[WARNING] 'dependencies.dependency.(groupId:artifactId:type:classifier)' must be unique: org.apache.httpcomponents:httpclient:jar -> duplicate declaration of version 4.3.5 @ line 351, column 15
[WARNING] 'dependencies.dependency.(groupId:artifactId:type:classifier)' must be unique: junit:junit:jar -> version ${junit.version} vs 4.12 @ line 361, column 15
[WARNING] 'dependencies.dependency.(groupId:artifactId:type:classifier)' must be unique: org.seleniumhq.selenium:selenium-htmlunit-driver:jar -> duplicate declaration of version 2.48.0 @ line 366, column 15
[WARNING] 'dependencies.dependency.(groupId:artifactId:type:classifier)' must be unique: info.cukes:cucumber-core:jar -> version ${cucumber.version} vs 1.2.5 @ line 392, column 15
[WARNING] 'dependencies.dependency.(groupId:artifactId:type:classifier)' must be unique: info.cukes:cucumber-core:jar -> version ${cucumber.version} vs 1.2.5 @ line 397, column 15
[WARNING] 'dependencies.dependency.(groupId:artifactId:type:classifier)' must be unique: com.codoid.products:fillo:jar -> version 1.14 vs 1.15 @ line 402, column 15
[WARNING] 'build.plugins.plugin.(groupId:artifactId)' must be unique but found duplicate declaration of plugin org.apache.maven.plugins:maven-compiler-plugin @ line 423, column 12
[WARNING] 'build.plugins.plugin.(groupId:artifactId)' must be unique but found duplicate declaration of plugin org.apache.maven.plugins:maven-surefire-plugin @ line 619, column 12
[WARNING] 'build.plugins.plugin.(groupId:artifactId)' must be unique but found duplicate declaration of plugin net.serenity-bdd.maven.plugins:serenity-maven-plugin @ line 652, column 12
[WARNING] 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-eclipse-plugin is missing. @ line 444, column 12
[WARNING]
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING]
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
[WARNING]
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building my-app 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ RMT_Regression ---
[INFO] Deleting C:\Users\Shashavalil\Documents\MCR\RMT_Regression\target
[INFO]
[INFO] --- cucumber-jvm-parallel-plugin:4.2.0:generateRunners (generateRunners) @ RMT_Regression ---
[WARNING] The format parameter is deprecated. Please use plugins
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4.588 s
[INFO] Finished at: 2018-04-17T12:43:58+05:30
[INFO] Final Memory: 15M/37M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal com.github.temyers:cucumber-jvm-parallel-plugin:4.2.0:generateRunners (generateRunners) on project RMT_Regression: Execution generateRunners of goal com.github.temyers:cucumber-jvm-parallel-plugin:4.2.0:generateRunners failed: Parser errors:
[ERROR] (358:1): inconsistent cell count within the table
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginExecutionException

@mpkorstanje
Copy link
Collaborator

[ERROR] (358:1): inconsistent cell count within the table

Fix the gherkin syntax.

@Shareef112
Copy link

@laddushashavali in your scenario outline Example you provided More values than columns or vice versa.
please fix that the issue will resolve

@Shareef112
Copy link

@mpkorstanje I tried all the combinations but still I am getting that error. Can you please help me to mitigate that error. if you want I can send my POM file

@mpkorstanje
Copy link
Collaborator

mpkorstanje commented Apr 17, 2018 via email

@Shareef112
Copy link

While running cucumber parallel plugin with surefire 2.21.0 with TestNG True then I am getting below error message. can anyone Help me to resolve this issue.

[**INFO] Running Parallel01IT
[ERROR] Tests run: 3, Failures: 2, Errors: 0, Skipped: 1, Time elapsed: 1.617 s <<< FAILURE! - in Parallel01IT
[ERROR] setUpClass(Parallel01IT) Time elapsed: 0.805 s <<< FAILURE!
java.lang.NoSuchMethodError: cucumber.runtime.RuntimeOptions.reporter(Ljava/lang/ClassLoader;)Lgherkin/formatter/Reporter;

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

[INFO]
[INFO] Results:
[INFO]
[ERROR] Failures:
[ERROR] Parallel01IT>AbstractTestNGCucumberTests.setUpClass:16 » NoSuchMethod cucumber...
[ERROR] Parallel01IT>AbstractTestNGCucumberTests.tearDownClass:34 » NullPointer
[INFO]
[ERROR] Tests run: 3, Failures: 2, Errors: 0, Skipped: 1
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------**------------------------------------------------

@alinpa
Copy link

alinpa commented Jul 18, 2018

Hello,

I am trying to run with the following conf:

com.github.temyers
cucumber-jvm-parallel-plugin
4.2.0
.....
true

The surefire:

org.apache.maven.plugins maven-surefire-plugin 2.20 ${surefireSkip} classes ${surefireThreadCount} 1 ${project.build.directory}/classes **/*IT.java 3 //It doesn't matter what version I have above.

I am not able to see the test which is failed to be run again.
Could you help me ?

@fescobar
Copy link

fescobar commented Aug 9, 2018

Could you add in this repo any complete example about how to implement re-run executions?
I see the txt files generated when I run in parallel:

                        <artifactId>cucumber-jvm-parallel-plugin</artifactId>
                        <version>5.0.0</version>
                        <executions>
                        ....
                                <configuration>
                                    <plugins>
                                        <plugin>
                                            <name>rerun</name>
                                            <outputDirectory>${CUCUMBER_FAILED_FOLDER_PATH}</outputDirectory>
                                        </plugin>
                                    </plugins>

but how can I use those txt files for rerunning?? I need to create another maven profile?
I tried to create another maven profile passing the txt folder as featuresDirectory, but it doesn't work

<featuresDirectory>${CUCUMBER_FAILED_FOLDER_PATH}</featuresDirectory>

It would be good if the doc was clear about that because it's a feature required for most testers.

@Shareef112
Copy link

Hi Team,

when I run tymers cucumber parllel plug in without TestNG i am able to achieve Rerun Functionolity. if I use testNG Rerun functionolity is not working.
can you please help me on this.
POM:

4.0.0

<groupId>cucumber</groupId>
<artifactId>cucumber-java-skeleton</artifactId>
<version>0.0.1</version>
<packaging>jar</packaging>
<name>Cucumber-Java Skeleton</name>

<properties>
    <java.version>1.8</java.version>
    <junit.version>4.12</junit.version>
    <cucumber.version>3.0.0</cucumber.version>
    <cucumber.pro.version>2.0.4</cucumber.pro.version>
    <maven.compiler.version>3.3</maven.compiler.version>
    <surefire.rerunFailingTestsCount>2</surefire.rerunFailingTestsCount>
</properties>

<dependencies>
    <dependency>
        <groupId>io.cucumber</groupId>
        <artifactId>cucumber-java</artifactId>
        <version>${cucumber.version}</version>
        <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>io.cucumber</groupId>
        <artifactId>cucumber-junit</artifactId>
        <version>${cucumber.version}</version>
        <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>io.cucumber</groupId>
        <artifactId>pro-plugin</artifactId>
        <version>${cucumber.pro.version}</version>
        <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>${junit.version}</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>io.cucumber</groupId>
        <artifactId>cucumber-testng</artifactId>
        <version>3.0.0</version>
        <exclusions>
            <exclusion>
                <groupId>junit</groupId>
                <artifactId>junit</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
    <dependency>
        <groupId>org.testng</groupId>
        <artifactId>testng</artifactId>
        <version>6.9.8</version>
        <scope>test</scope>
    </dependency>
</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>com.github.temyers</groupId>
            <artifactId>cucumber-jvm-parallel-plugin</artifactId>
            <version>5.0.0</version>
            <executions>
                <execution>
                    <id>generateRunners</id>
                    <phase>generate-test-sources</phase>
                    <goals>
                        <goal>generateRunners</goal>
                    </goals>
                    <configuration>
                        <!-- Mandatory -->
                        <!-- List of package names to scan for glue code. -->
                        <glue>
                            <package>skeleton</package>
                        </glue>
                        <!-- These are optional, with the default values -->
                        <!-- Where to output the generated tests -->
                        <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>src/test/resources/</featuresDirectory>
                        <!-- Directory where the cucumber report files shall be written  -->
                        <cucumberOutputDir>target/cucumber-parallel</cucumberOutputDir>
                        <!-- List of cucumber plugins. When none are provided the json formatter is used. For more
                             advanced usage see section about configuring cucumber plugins -->
                        <plugins>
                            <plugin>
                                <name>json</name>
                            </plugin>

                        </plugins>
                        <!-- CucumberOptions.strict property -->
                        <strict>true</strict>
                        <!-- CucumberOptions.monochrome property -->
                        <monochrome>true</monochrome>
                        <!-- The tags to run, maps to CucumberOptions.tags property. Default is no tags. -->
                        <tags>
                            <tag>@belly</tag>
                        </tags>
                        <!-- Generate TestNG runners instead of JUnit ones. -->
                        <useTestNG>true</useTestNG>
                        <!-- The naming scheme to use for the generated test classes.  One of ['simple', 'feature-title', 'pattern'] -->
                        <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>SCENARIO</parallelScheme>
                    </configuration>
                </execution>
            </executions>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>2.22.0</version>
            <executions>
                <execution>
                    <id>acceptance-test</id>
                    <phase>integration-test</phase>
                    <goals>
                        <goal>test</goal>
                    </goals>
                    <configuration>
                        <forkCount>1</forkCount>
                        <includes>
                            <include>**/*IT.java</include>
                        </includes>
                    </configuration>
                </execution>
            </executions>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>${maven.compiler.version}</version>
            <configuration>
                <encoding>UTF-8</encoding>
                <source>${java.version}</source>
                <target>${java.version}</target>
                <compilerArgument>-Werror</compilerArgument>
            </configuration>
        </plugin>

    </plugins>
</build>

@fescobar
Copy link

@Shareef112 #176

@mourya2175
Copy link

Hello Team,

I am using testngRunner to run my cucumber features..i am using temyers/cucumber-jvm-parallel-plugin to execute scripts in parallel using selenium grid. I was able to see 1.txt and 2.txt is the test is failed. but i didnt know how to re run failed scripts...could you please help me. Attached are my pom.xml and .vm template.

@mourya2175
Copy link


4.0.0

<groupId>com.project</groupId>
<artifactId>MyAutomation</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>

<name>MyAutomation</name>
<url>http://maven.apache.org</url>

<properties>
	<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
	<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
	<java.version>1.8</java.version>
	<!--Plugin Versions -->
	<maven-compiler-plugin.version>3.6.1</maven-compiler-plugin.version>
	<cucumber.version>1.2.5</cucumber.version>
	<maven-surefire-plugin.version>2.19.1</maven-surefire-plugin.version>
	<maven-cucumber-reporting.version>3.15.0</maven-cucumber-reporting.version>
	<cucumber-jvm-parallel-plugin.version>4.2.0</cucumber-jvm-parallel-plugin.version>
	<hrcPantherFrameworkVersion>0.0.2</hrcPantherFrameworkVersion>
	<suiteFile>testng.xml</suiteFile>
	<browser />
	<threads />
	<remoteDriver />
	<seleniumGridUrl />
	<cucumberOutputDirectory>${project.build.directory}/cucumber</cucumberOutputDirectory>
	<include.runners />
	<platform />
	<desiredBrowserVersion />
	<proxyEnabled />
	<proxyHost />
	<proxyPort />
</properties>

<dependencies>
	<dependency>
		<groupId>com.project</groupId>
		<artifactId>hrcPantherFramework</artifactId>
		<version>${hrcPantherFrameworkVersion}-SNAPSHOT</version>
	</dependency>

	<dependency>
		<groupId>log4j</groupId>
		<artifactId>log4j</artifactId>
		<version>1.2.17</version>
	</dependency>
	<dependency>
		<groupId>info.cukes</groupId>
		<artifactId>cucumber-testng</artifactId>
		<version>1.2.5</version>
		<scope>compile</scope>
		<exclusions>
			<exclusion>
				<groupId>junit</groupId>
				<artifactId>junit</artifactId>
			</exclusion>
		</exclusions>
	</dependency>

	<dependency>
		<groupId>info.cukes</groupId>
		<artifactId>cucumber-picocontainer</artifactId>
		<version>1.2.5</version>
		<scope>test</scope>
	</dependency>

</dependencies>

<profiles>

	<!--'parallelPlugin' profile is executing tests in parallel - with cucumber-jvm-parallel-plugin -->
	<profile>
		<id>parallelPlugin</id>
		<properties>
			<include.runners>**/Parallel*IT.class</include.runners>
		</properties>
		<build>
			<plugins>
				<plugin>
					<groupId>com.github.temyers</groupId>
					<artifactId>cucumber-jvm-parallel-plugin</artifactId>
					<version>${cucumber-jvm-parallel-plugin.version}</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>
									<!-- <package>lv.iljapavlovs.cucumber.stepdefs</package> <package>lv.iljapavlovs.cucumber.hooks</package> -->
									<package>com.stepdefinitions</package>
								</glue>
								<!-- These are optional, with the default values -->
								<!-- Where to output the generated tests -->
								<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>src/test/resources</featuresDirectory>
								<!-- Directory where the cucumber report files shall be written -->
								<cucumberOutputDir>${cucumberOutputDirectory}</cucumberOutputDir>
								<!-- List of cucumber plugins. When none are provided the json formatter 
									is used. For more advanced usage see section about configuring cucumber plugins -->
								<plugins>
									<plugin>
										<!--The available options are junit, testng, html, pretty, json, 
											usage and rerun -->
										<name>json</name>
									</plugin>
									<plugin>
										<!--The available options are junit, testng, html, pretty, json, 
											usage and rerun -->
										<name>com.cucumber.listener.ExtentCucumberFormatter:target/cucumber-test-reports</name>
									</plugin>
									<!-- <plugin> The available options are junit, testng, html, pretty, 
										json, usage and rerun <name>com.cucumber.listener.ExtentCucumberFormatter:target/cucumber-test-reports/KachhingReport.html</name> 
										</plugin> -->
									<plugin>
										<name>pretty</name>
									</plugin>
								</plugins>
								<!-- CucumberOptions.strict property -->
								<strict>true</strict>
								<!-- CucumberOptions.monochrome property -->
								<monochrome>false</monochrome>
								<!--The tags to run, maps to CucumberOptions.tags property -->
								<tags>${tags}</tags>
								<!-- <tags> <tag>@2409</tag> Currently multiple tags not working 
									<tag>@cheese</tag> <tag>@milk</tag> </tags> -->
								<!-- Generate TestNG runners instead of JUnit ones. -->
								<useTestNG>false</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>
								<!-- Specify a custom template for the generated sources (this is 
									a path relative to the project base directory) -->
								<customVmTemplate>src/test/resources/custom-runner-template.java.vm
								</customVmTemplate>
								<!-- Specify a custom package name for generated sources. Default 
									is no package. -->
								<!--<packageName></packageName> -->
							</configuration>
						</execution>
					</executions>
				</plugin>
			</plugins>
		</build>
	</profile>
	<profile>
		<id>grid</id>
		<build>
			<plugins>

				<plugin>
					<groupId>org.apache.maven.plugins</groupId>
					<artifactId>maven-surefire-plugin</artifactId>
					<version>${maven-surefire-plugin.version}</version>
					<configuration>
						<testFailureIgnore>true</testFailureIgnore>
						<forkCount>${threads}</forkCount>
						<reuseForks>false</reuseForks>
						<includes>
							<include>**/*CukesTest.java</include>
							<include>${include.runners}</include>
						</includes>
						<systemPropertyVariables>
							<screenshotDirectory>${project.build.directory}/screenshots</screenshotDirectory>
						</systemPropertyVariables>
					</configuration>
					<executions>
						<execution>
							<id>execution</id>
							<phase>test</phase>
							<goals>
								<goal>test</goal>
							</goals>
							<configuration>
								<projectName>MyAutomation</projectName>
								<outputDirectory>${project.build.directory}/site/cucumber-reports</outputDirectory>
								<cucumberOutput>${cucumberOutputDirectory}</cucumberOutput>
								<skippedFails>true</skippedFails>
								<buildNumber>${project.version}</buildNumber>
								<!-- shows additional column in report - 'Device' -->
								<parallelTesting>true</parallelTesting>
							</configuration>
						</execution>
					</executions>
				</plugin>


				<plugin>
					<groupId>net.masterthought</groupId>
					<artifactId>maven-cucumber-reporting</artifactId>
					<version>${maven-cucumber-reporting.version}</version>
					<executions>
						<execution>
							<id>execution</id>
							<phase>verify</phase>
							<goals>
								<goal>generate</goal>
							</goals>
							<configuration>
								<projectName>MyAutomation</projectName>
								<outputDirectory>${project.build.directory}/site/cucumber-reports</outputDirectory>
								<cucumberOutput>${cucumberOutputDirectory}</cucumberOutput>
								<!--<skippedFails>true</skippedFails> -->
								<buildNumber>${project.version}</buildNumber>
								<!--shows additional column in report - 'Device' -->
								<parallelTesting>true</parallelTesting>
							</configuration>
						</execution>
					</executions>
				</plugin>
			</plugins>
		</build>
	</profile>

	<profile>
		<id>nogrid</id>
		<build>
			<plugins>
				<plugin>
					<groupId>org.apache.maven.plugins</groupId>
					<artifactId>maven-surefire-plugin</artifactId>
					<version>${maven-surefire-plugin.version}</version>
					<configuration>
						<suiteXmlFiles>${suiteFile}</suiteXmlFiles>
					</configuration>
				</plugin>
			</plugins>
		</build>
	</profile>
</profiles>


<build>
	<plugins>
		<plugin>
			<groupId>org.apache.maven.plugins</groupId>
			<artifactId>maven-compiler-plugin</artifactId>
			<configuration>
				<source>${java.version}</source>
				<target>${java.version}</target>
			</configuration>
			<version>${maven-compiler-plugin.version}</version>
		</plugin>
	</plugins>
</build>

@mourya2175
Copy link


#macro( stringArray $array ){#foreach( $element in $array )"$element"#if( $foreach.hasNext ), #end#end}#end
#if ($packageName)package $packageName;
#end##
import cucumber.api.CucumberOptions;
import cucumber.api.testng.AbstractTestNGCucumberTests;

@CucumberOptions(
strict = $strict,
features = {"$featureFile"},
plugin = #stringArray($plugins),
monochrome = $monochrome,
#if(!$featureFile.contains(".feature:") && $tags)
tags = #stringArray($tags),
#end
glue = #stringArray($glue))
public class $className extends AbstractTestNGCucumberTests{

}

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests