In spring / junit, you can load application context files using @ContextConfiguration , e.g.
@ContextConfiguration({"classpath:a.xml", "classpath:b.xml"})
I have a requirement when I see a special annotation on a test class, then dynamically add another XML file. For instance:
@ContextConfiguration({"classpath:a.xml", "classpath:b.xml"}) @MySpecialAnnotation class MyTest{ ... }
In the above example, I would like to search @MySpecialAnnotation and add special-context.xml . What is the best way to do this? I looked at this for a while, and it seems that subclassing for my own ContextLoader , which is one of the @ContextConfiguration options, is the best approach? It's right? Is there a better way to do this?
source share