I'm facing problems when running a Test Suite of JUnit 5 Jupiter with Spring.
I'm using latest version of Spring (5.2.8-RELEASE) (not spring-boot) and latest version of JUnit Jupiter (5.7.0).
Here is my Test Suite code:
package mypackage.test;
import org.junit.jupiter.api.MethodOrderer.OrderAnnotation;
import org.junit.jupiter.api.TestInstance;
import org.junit.jupiter.api.TestInstance.Lifecycle;
import org.junit.jupiter.api.TestMethodOrder;
import org.junit.jupiter.api.extension.ExtendWith;
import org.junit.platform.suite.api.SelectPackages;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import org.springframework.test.context.web.AnnotationConfigWebContextLoader;
import org.springframework.test.context.web.WebAppConfiguration;
@WebAppConfiguration
@ExtendWith(SpringExtension.class)
@ContextConfiguration(loader = AnnotationConfigWebContextLoader.class, classes = {
MyRootSpringConfiguration.class })
@SelectPackages("mypackage.test.units")
class MyTestSuite {
}
This way, I'm loading the context of the application, and then I want to execute all the corresponding tests.
But it seems not working, as Eclipse doesn't recognize this Class as JUnit 5 Test Class.
I have a similar configuration for the individual Test Classes, and they work fine. But each file loads the context, and that's not a good solution. I prefer to have a Suite that loads the context once, and then all the Tests uses this context to be executed.
Any idea about how to configure it?