Reference URLs:
- https://yuangaopeng.com/2018/12/05/Spring%20Testing%20classpath/
- https://docs.spring.io/spring/docs/3.0.x/spring-framework-reference/htmlsingle/spring-framework-reference.html#integration-testing-annotations
For JUnit test with spring, either you load context configuration:
- manual parse xml [ApplicationContext _ctx = ClassPathXmlApplicationContext( "abc/xyz/spring-context-all.xml" ) ], access beans via _ctx.getBean()
- or annotation to let spring auto wired all your attributes of test cases.
And using annotation of @ContextConfiguration, I've preference to use classpath for reasons below:
- Spring JUnit test cases able to share xml info.
- multi developer environment competible.