GithubHelp home page GithubHelp logo

tiwariswapnil / cucumber_parallel_execution_junit Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 1.0 26.32 MB

Automation framework to run cucumber tests in parallel using JUnit, Maven Surefire plugin, Maven FailSafe plugin and Java Callable

License: MIT License

Java 95.80% Gherkin 4.20%
junit surefire-plugin callable java cucumber failsafe-plugin maven

cucumber_parallel_execution_junit's Introduction

cucumber_parallel_execution

Maven Surefire plugin

Cucumber tests can be exectued in parallel using JUnit and Maven test execution plugins.

In JUnit the feature files are run in parallel rather than scenarios. All the scenarios in the feature file get executed by the same thread.

We can use the Maven Surefire plugin to run feature files in parallel.

  1. Add the plugin in the pom file. Update the configurations as required-
<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-surefire-plugin</artifactId>
    <version>2.22.0</version>
    <configuration>
        <parallel>methods</parallel>
        <threadCount>2</threadCount>
        <perCoreThreadCount>true</perCoreThreadCount>
    </configuration>
</plugin>
  1. Run the following cmd in terminal to run the feature files in parallel-
    mvn verify

Maven FailSafe Plugin

Plugin Goals

The failsafe plugin is used for integration tests of a project. It has two goals:

  1. integration-test โ€“ run integration tests; this goal is bound to the integration-test phase by default
  2. verify โ€“ verify that the integration tests passed; this goal is bound to the verify phase by default

We can use the Maven FailSafe plugin to run feature files in parallel.

  1. Add the plugin in the pom file. Update the configurations as required-
<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-failsafe-plugin</artifactId>
    <version>3.0.0-M5</version>
    <executions>
        <execution>
            <goals>
                <goal>integration-test</goal>
                <goal>verify</goal>
            </goals>
            <configuration>
                <includes>
                    <include>**/TestRunner.java</include>
                </includes>
                <parallel>methods</parallel>
                <threadCount>2</threadCount>
                <perCoreThreadCount>true</perCoreThreadCount>
            </configuration>
        </execution>
    </executions>
</plugin>
  1. Run the following cmd in terminal to run the feature files in parallel-
    mvn verify

Surefire plugin vs Failsafe plugin

This plugin runs methods in test classes just like the surefire plugin. We can configure both plugins in similar ways. However, there're some crucial differences between them.

First, unlike surefire which is included in the super pom.xml, the failsafe plugin with its goals must be explicitly specified in the pom.xml to be part of a build lifecycle:

Second, the failsafe plugin runs and verifies tests using different goals. A test failure in the integration-test phase doesn't fail the build straight away, allowing the phase post-integration-test to execute, where clean-up operations are performed.

Failed tests, if any, are only reported during the verify phase, after the integration test environment has been torn down properly.

Callable

Java Callable can be used to run particular tasks in parallel.

Reference:

Please refer to '/src/test/java/com/github/automation/junit/tests/ParallelTests.java' for sample usage of Callable

cucumber_parallel_execution_junit's People

Contributors

tiwariswapnil avatar

Stargazers

 avatar

Watchers

 avatar

Forkers

lavinzaw

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.