Cucumber integration with TestNG and Maven
Java
Latest commit 8fe783f Apr 26, 2016 @igorvsd igorvsd write stacktrace on retry

README.md

Cucumber-TestNg

If you ever dreamt about running cucumber test with testng look into this project :).

Configuration:

You need to put configuration file in your project like:

src/test/resources/cucumber.properties with content:


# java package with steps classes in your project
cucumber.steps.package=com.yourpackage

To check you didn't forget to implement TestNG @Test add such additional test:


public class StateTest {

    @Test(priority = -1)
    public void testState() {
        // setup

        // act
        String result = CucumberTestsStateUtil.checkTests();

        // verify
        Assert.assertNull(result, result);
    }
}

Then for each feature scenario you need to create TestNG test. Feature Name shoud be same as feature file name Scenario name should be same as feature scenario name in cucumber

src/test/java/com/example/LoginTest.java



@Feature("login")
public class LoginTest extends AbstractCucumberTest {

    @Test
    @Scenario("Login with guest account")
    public void loginWithGuestAccount() {
        run();
    }

resources/com/example/test/login.feature


Feature: Login

  Scenario: Login with guest account
    Given Prepared user with username <"SuccessfulUsername"> and password <"12345">
    Then Open login page
    Then Fill login form with user <"SuccessfulUsername"> and password <"12345"> and click login
    Then Check we logged in with username <"SuccessfulUsername">

Changelog:

0.1.1

  • [+] CucumberTestsStateUtil. Added check tests names are unique because cucumber starts tests using regexp instead check name for equal (so one test name shouldn't start with another test name)

0.1.0

  • [+] Feature. Retry run failed test support added. Need to be added java property at runtime -Dretry.tests=3 to rerun this test max 3 times more if it failed at first run. 0 by default.