2019-05-14

Spring 3.0 with JUnit Test 4


Reference URLs:

  1. https://yuangaopeng.com/2018/12/05/Spring%20Testing%20classpath/
  2. 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:

  1. manual parse xml [ApplicationContext _ctx = ClassPathXmlApplicationContext( "abc/xyz/spring-context-all.xml" ) ], access beans via _ctx.getBean()
  2. 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:

  1. Spring JUnit test cases able to share xml info.
  2. multi developer environment competible.











No comments:

Google Referrals