Spring's website gives the following ways to initialize context for integration tests:
@ContextConfiguration("/test-config.xml")
public class XmlApplicationContextTests {
// class body...
}
and
@ContextConfiguration(classes = TestConfig.class)
public class ConfigClassApplicationContextTests {
// class body...
}
But for both ways I have to create a second file, either xml or java class, which seems to be redundant for a small test.
Question: Is there a way to configure context right inside the test class itself? I tried to put both @Configuration & @ComponentScan(...)
and @ContextConfiguration(classes = MyTestClass.class)
on MyTestClass
, but it fails to load.
Aucun commentaire:
Enregistrer un commentaire