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.