We have a Spring-based JUnit test class that uses the internal test context configuration class
@RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(classes = ServiceTest.Config.class) public class ServiceTest { @Test public void someTest() { ... @Configuration @PropertySource(value = { "classpath:application.properties" }) @ComponentScan({ "..." }) public static class Config { ...
Recently, new functions of the Service class have been added, for which the corresponding tests should be added to ServiceTest. However, for this, you will also need to create another testing context configuration class (the interiors of the existing configuration class are quite complex and changing it to serve both old and new tests will seem to be extremely complex, if possible at all)
Is there a way to achieve that some test methods in one test class will use one configuration class and other methods will use another? @ContextConfiguration seems to be applicable only at the class level, so the solution may be to create another test class for new tests that will use their own context configuration class; but that would mean that the same class of service extends through two different test classes
source share