I have parametrized integration test, that I run with maven-surefire-plugin.
They use a wiremock server, which send different value for each parameters.
When I launch all the tests, they are not consistent , it's never the same test who are OK and KO. If I relaunch only the failed, more and more passed, until they are all OK.
I suspect a concurrence issue.
But ow Can I know if the issue is on maven , surfire, intelliji or in the Parametrized Runner?
How can I force maven or intelliji or Parametrized to run the test methode one by one, one classe by one?
The code:
@RunWith(Parameterized.class)
public class InfoIT {
@Parameterized.Parameters(name = "cache: {0}")
public static List<Object[]> getParameters() {
return asList(new Object[][]{
{"infoA"},
{"infoB"},
{"infoC"},
{"infoD"}
});
}
@Parameterized.Parameter(0)
public String cache;
@Rule
public WireMockRule siteServer = new WireMockRule(WIREMOCK_SITESERVER_CONFIGURATION);
WebTarget infoClient = ClientBuilder.newClient().target(INFO_URL);
@Test
public void test_delete_is_ok_with_private_ip() {
// when
Response response = infoClient.path(format("/private/%s/test", cache)).request().delete();
// then
assertResponseEmpty(response);
}
You could annotate the class InfoIT
with @NotThreadSafe
(from net.jcip:jcip-annotations:1.0), this will make the tests run sequentially (source: https://maven.apache.org/surefire/maven-failsafe-plugin/examples/fork-options-and-parallel-execution.html). If that's what you are asking.