3

I want to re-run failed tests with maven. I'm using surefire.rerunFailingTestsCount for this:

mvn '-Dtest=LoginTest#loginAsValidUser' '-Dsurefire.rerunFailingTestsCount=1'clean test

However, after tests fail, they are not found again by junit when trying to re-run:

org.junit.runner.manipulation.Filter.initializationError(org.junit.runner.manipulation.Filter)
  Run 1: Filter.initializationError »  No tests found matching Method loginAsValidUser[...
  Run 2: Filter.initializationError »  No tests found matching Method loginAsValidUser[...
  Run 3: Filter.initializationError »  No tests found matching Method loginAsValidUser[...

According to maven documentation, test method can be also indicated with [*], so I tried

mvn '-Dtest=LoginTest#loginAsValidUser[*]' -Dsurefire.rerunFailingTestsCount=1 clean test

and different variations of specifying test class/methods name, but outcome is the same. Any ideas what is causing this?

maven-surefire plugin version is 2.19.1, junit version is 4.12, junitparams version is 1.0.5.

Test class looks like this:

@RunWith(JUnitParamsRunner.class)
public class LoginTest {

    @Test
    @FileParameters(value = "src/main/resources/login_data.csv")
    @TestCaseName("{method}[{index}]")
    public void loginAsValidUser(String username, String password) {
        //test
    }
}

UPDATE: I found surefire bugreport for similar situation but that was fixed. I took sample code that demonstrated the bug and run it, worked well. Then I changed runner to junitparams runner and got same error a described above. I guess this may be a bug with runner, so I opened issue on their github.

bukva-ziu
  • 126
  • 8
  • Did you try it without the ' around the commandline parameters? – Nitek Aug 03 '16 at 06:36
  • The same doesn't work for me with `WebDriverRunner`. Have you had any progress on the issue? – Alexey Subach Feb 09 '17 at 08:29
  • @AlexeySubach I eventually gave up and did an implementation based on [this](http://stackoverflow.com/questions/8295100/how-to-re-run-failed-junit-tests-immediately) – bukva-ziu Feb 12 '17 at 21:53

0 Answers0