Description
Chris Beams opened SPR-6184 and commented
Currently, JavaConfig integrates with the TestContext framework via its ContextLoader
implementation, JavaConfigContextLoader
:
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations="com.bank.TransferAppConfig",
loader=JavaConfigContextLoader.class)
public class TransferServiceTests {
// @Test methods ...
}
This integration works well enough but is not refactoring-friendly due to the requirement that @ContextConfiguration
imposes that locations must be a String[]
. It forces the fully-qualified class name to be expressed as a string, when it would clearly be superior to be able to pass it around by Class
literal.
Implementing this change would require a change to core, either by adding an attribute to @ContextConfiguration
that takes a Class[]
(not likely), or otherwise devising a way of proving a customized annotation (e.g., @JavaConfigContextConfiguration
).
Affects: 3.0 GA
Issue Links:
- Introduce SmartContextLoader SPI [SPR-8386] #13033 Introduce SmartContextLoader SPI ("is depended on by")
- Document TestContext support for @Configuration classes in the reference manual [SPR-8240] #12888 Document TestContext support for
@Configuration
classes in the reference manual ("is depended on by") - SpringJUnit4ClassRunner is not compatible with java context configuration [SPR-7769] #12425 SpringJUnit4ClassRunner is not compatible with java context configuration ("is duplicated by")
- Annotation configuration based TestContext [SPR-6567] #11233 Annotation configuration based TestContext ("is duplicated by")
- SJC-272 JavaConfigContextLoader support with Spring 3.0 ("is duplicated by")
- AnnotationConfigContextLoader should not restrict the name of default configuration classes to ContextConfiguration [SPR-8395] #13042 AnnotationConfigContextLoader should not restrict the name of default configuration classes to ContextConfiguration
- TestContext framework should support declarative configuration of bean definition profiles [SPR-7960] #12615 TestContext framework should support declarative configuration of bean definition profiles
- Support for dependency injection and initialization of test instances using classpath scanning [SPR-7937] #12592 Support for dependency injection and initialization of test instances using classpath scanning
- Provide dedicated ApplicationContext implementations for use with (JavaConfig) @Configuration classes [SPR-5682] #10353 Provide dedicated ApplicationContext implementations for use with (JavaConfig)
@Configuration
classes - Support Java-Based Application Configuration [SPR-7420] #12078 Support Java-Based Application Configuration
37 votes, 30 watchers