Maven Surefire plugin did not repeat unsuccessful cucumber tests

I am using the Java implementation of Selenium WebDriver ( version 2.53.0 ) to run some automated tests against a web application. Tests are recorded in a behavior testing format using the Java Cucumber implementation ( version 1.2.3 ). I use Maven ( version 3.3.9 ) to import all my dependencies, as well as to create and run tests. Tests are organized into different categories using cucumber tags. For example, I can run one category of tests with @JohnnyBravo tags from the command line using the following commands:

cd path_to_Maven_POM_file mvn clean test -Dcucumber.options="--tags @JohnnyBravo" 

After some research, I found out that you can use the Maven SureFire plugin to run failed tests again by adding " -Dsurefire.rerunFailingTestsCount=2 " to the Maven command above according to this link . Then I tried to repeat this category of tests using the command below, ensuring that some of them would fail, in order to check whether they would be repeated or not:

 mvn clean test -Dcucumber.options="--tags @JohnnyBravo" -Dsurefire.rerunFailingTestsCount=2 

Unfortunately, failed tests did not resume. What am I doing wrong here?

My POM file is shown below:

 <?xml version="1.0" encoding="UTF-8"?> <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> <groupId>com.company</groupId> <artifactId>regression-test</artifactId> <version>0.0.1-SNAPSHOT</version> <properties> <cucumber.version>1.2.3</cucumber.version> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> </properties> <dependencies> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.12</version> </dependency> <dependency> <groupId>joda-time</groupId> <artifactId>joda-time</artifactId> <version>2.8.2</version> </dependency> <dependency> <groupId>net.sourceforge.jtds</groupId> <artifactId>jtds</artifactId> <version>1.3.1</version> </dependency> <dependency> <groupId>info.cukes</groupId> <artifactId>cucumber-picocontainer</artifactId> <version>${cucumber.version}</version> </dependency> <dependency> <groupId>info.cukes</groupId> <artifactId>cucumber-java</artifactId> <version>${cucumber.version}</version> </dependency> <dependency> <groupId>info.cukes</groupId> <artifactId>cucumber-junit</artifactId> <version>${cucumber.version}</version> </dependency> <dependency> <groupId>com.vimalselvam</groupId> <artifactId>cucumber-extentsreport</artifactId> <version>1.1.0</version> </dependency> <dependency> <groupId>org.seleniumhq.selenium</groupId> <artifactId>selenium-java</artifactId> <version>2.53.0</version> </dependency> <dependency> <groupId>commons-io</groupId> <artifactId>commons-io</artifactId> <version>2.4</version> </dependency> <dependency> <groupId>com.pojosontheweb</groupId> <artifactId>monte-repack</artifactId> <version>1.0.1</version> </dependency> </dependencies> <build> <pluginManagement> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <version>2.18.1</version> </plugin> </plugins> </pluginManagement> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <version>2.18.1</version> <configuration> <systemPropertyVariables> <webdriver.chrome.driver>src/test/resources/chromedriver/chromedriver.exe</webdriver.chrome.driver> </systemPropertyVariables> <!--<testFailureIgnore>true</testFailureIgnore>--> </configuration> </plugin> <plugin> <artifactId>maven-compiler-plugin</artifactId> <version>3.1</version> <configuration> <source>1.7</source> <target>1.7</target> </configuration> </plugin> </plugins> </build> </project> 

The Cucumber Jucit test runner class is shown below:

 import com.cucumber.listener.ExtentCucumberFormatter; import cucumber.api.CucumberOptions; import cucumber.api.junit.Cucumber; import org.junit.BeforeClass; import org.junit.runner.RunWith; import java.io.File; import java.util.HashMap; @RunWith(Cucumber.class) @CucumberOptions( monochrome = false, plugin = { "pretty", "html:C:/Test_Output_Data/Results/HTML/", "json:C:/Test_Output_Data/Results/results.json", "com.cucumber.listener.ExtentCucumberFormatter" }, features = {"src/test/resources/"}, tags = { "@JohnnyBravo", //"@AgentUI", "@Smoke", //"@GenUI", "@Smoke", //"@GenUI", "@Regression", } ) public class GeneralRunnerTest { @BeforeClass public static void setup() { ExtentCucumberFormatter.initiateExtentCucumberFormatter(); ExtentCucumberFormatter.loadConfig(new File("src/test/resources/extent-config.xml")); ExtentCucumberFormatter.addSystemInfo("Browser Name", "Firefox"); ExtentCucumberFormatter.addSystemInfo("Browser version", "46.0.1"); ExtentCucumberFormatter.addSystemInfo("Selenium version", "2.53.0"); HashMap<String, String> systemInfo = new HashMap<>(); systemInfo.put("Cucumber Version", "1.2.3"); systemInfo.put("Extent Cucumber Reporter Version", "1.1.0"); ExtentCucumberFormatter.addSystemInfo(systemInfo); } } 
+5
source share

All Articles