I have several test classes that are annotated with @SpringBootTest
and also AutoConfigureMockMvc
.
They look like this:
@SpringBootTest
@AutoConfigureMockMvc
class ThymeleafFormatIT {
@Autowired
lateinit var mvc: MockMvc
@Test
fun `test something` {}
}
Since there are several of these tests, currently five, I want to run the test classes in parallel. I want to take the time it takes to run these tests down as far as possible.
Since I use Junit 5 and Maven, I have configured my failsafe plugin like this:
<plugin>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.22.0</version>
<executions>
[...]
</executions>
<configuration>
<properties>
<configurationParameters>
junit.jupiter.execution.parallel.enabled = true
junit.jupiter.execution.parallel.mode.default = same_thread
junit.jupiter.execution.parallel.mode.classes.default = concurrent
</configurationParameters>
</properties>
</configuration>
</plugin>
If I run now mvn integration-test
I see that multiple Spring containers get booted up, but they boot sequentially. Also, the test execution duration does not change significantly: before adding the configuration, duration was ~20 seconds, after adding it's ~19.9 seconds.
Is there something I am missing? Does the @SpringBootTest
annotation force sequential execution, maybe by blocking a port or something? Does the failsafe plugin not pick up the configuration items? Are Junit 5 and failsage incompatible with each other?