4

I couldn't find best solution for running cucumber test scenarios in parallel using gradle

The best possible solution found so far is this.. but I can't run it locally successfully

Any help much appreciated!!

Thanks in advance.

user861594
  • 5,733
  • 3
  • 29
  • 45
Ranjith's
  • 4,508
  • 5
  • 24
  • 40

2 Answers2

8

Take a look at Courgette-JVM

You can execute this with a gradle task.

It has added capabilities to run cucumber tests in parallel on a feature level or on a scenario level.

It also provides an option to automatically re-run failed scenarios.

Usage

@RunWith(Courgette.class)
@CourgetteOptions(
    threads = 10,
    runLevel = CourgetteRunLevel.SCENARIO,
    rerunFailedScenarios = true,
    showTestOutput = true,
    cucumberOptions = @CucumberOptions(
            features = "src/test/resources/features",
            glue = "steps",
            tags = {"@regression"},
            plugin = {
                    "pretty",
                    "json:target/courgette-report/courgette.json",
                    "html:target/courgette-report/courgette.html"}
    ))
    public class RegressionTestSuite {
    }
  • Thanks @Prashant Ramcharan!! I'll take a look. – Ranjith's May 10 '17 at 09:55
  • Unable to download the jar from maven or grade?? – Ranjith's May 10 '17 at 10:17
  • The JAR is on jcenter. In your build file - add jcenter to your repository. – Prashant Ramcharan May 10 '17 at 10:52
  • 1
    In your build.gradle add this: repositories { jcenter() } – Prashant Ramcharan May 10 '17 at 11:02
  • `/gradlew regressionSuite` is not running any tests.. it's simply giving me build success!! Any idea?? – Ranjith's May 10 '17 at 14:11
  • Where is the test class located in your project, is it on your test class path? Is the class name RegressionTestSuite? Note: I will add an example project soon! Watch the repo if you still interested. – Prashant Ramcharan May 10 '17 at 15:21
  • it's in `/src/test/resources` and specified `include '**/RegressionTestSuite.class'` in build task!! with correct name. – Ranjith's May 10 '17 at 15:32
  • 1
    The RegressionTestSuite class needs to be in src/test/java. Your feature files should be in src/test/resources – Prashant Ramcharan May 10 '17 at 16:09
  • One more question: how about passing courgette options from command line like for ex: tags ("~@WIP") ?? – Ranjith's May 11 '17 at 10:50
  • 1
    Courgette uses JUnit to execute the tests and currently I've not included a Courgette CLI runner. Having said that, you can still specify multiple tags in the runner itself like so: tags = { "@regression", "~@WIP" } – Prashant Ramcharan May 11 '17 at 18:13
  • is it possible to include project name, version and environmental details in courgette reports (FYI: I've added question here: https://stackoverflow.com/questions/64331536/courgette-jvm-to-include-project-name-version-and-environment-in-the-reports) – Ranjith's Oct 13 '20 at 11:46
  • @PrashantRamcharan - looks good - are there any plans to address CVSS vulnerabilities? We cant use this in our organization until these are addressed. – Plaiska Nov 15 '20 at 19:30
  • @Plaiska all security vulnerabilities have been addressed in version 5.8.0 – Prashant Ramcharan Nov 22 '20 at 23:48
  • @prashant ramcharan - we were able to import courgette in our organization , all vulnerabilities are indeed addressed. Thank you – Plaiska Nov 24 '20 at 04:04
  • @PrashantRamcharan I have sucessfully added the Courgette in my test runner class, but the issue is when execution happens, its not able to find the stepdefinationas and throws error. features = "classpath:features", glue = "stepDefinations", – Sobhit Sharma Jan 17 '21 at 13:43
0

You should try gherkin client of QMetry Automation Framework. By using it you can run individual scenario in parallel. You will get features like TestNG xml run configuration, detailed reporting, parallel execution, step listener and many more.

In order to convert existing cucumber-jvm project to QAF following are the stpes:

  • Download blank project QAF-bank-project ANT+IVY or qaf-blank-project-gradle or qaf-blank-project-maven
  • Copy your features files into scenario directory
  • Copy your java src files into src directory
  • Place @QAFTestStepProvider annotation at class defining cucumber steps
  • Create XML configuration file and run. You will find sample xml configuration file under config dir. For Gherkin your config file should look like below:
<test name="Gherkin-QAF-Test">
   <parameter name="step.provider.pkg" value="your.pkg.where.steps.defined" />
   <parameter name="scenario.file.loc" value="resources/features" />
   <classes>
      <class name="com.qmetry.qaf.automation.step.client.gherkin.GherkinScenarioFactory" />
   </classes>
</test>

You can use tags as groups for run-configuration-filter and all other TestNG and QAF features.

user861594
  • 5,733
  • 3
  • 29
  • 45
  • is it possible to convert my existing cucumber-jvm project to QAF?? (using gradle, cucumber, junit and java) – Ranjith's Mar 06 '17 at 11:13