Tuesday, May 7, 2013

Challenges while developing test for spring beans

Spring provides us options to test beans in application contexts using spring-test module. The detailed explanation of the way to use it can be accessed from the following link

I had maven based application. During the development and running of these test cases, I came accross few challenges. The key ones along with their resolutions are as mentioned below.

Issue - Compilation failure - SpringJUnit4ClassRunner.class and @ContextConfiguration not found
Solution - Included below mentioned maven dependency in the project and executed mvn eclipse:eclipse


Issue - IDE displying error - The type org.junit.runners.BlockJUnit4ClassRunner cannot be resolved. It is indirectly referenced from required .class files
Solution - BlockJUnit4ClassRunner was included in Junit4.5 so added below mentioned dependency of junit4.5 and executed mvn eclipse:eclipse



  1. Thanks, updating JUnit to version 4.5 did the trick.

  2. Thanks sooooo Usefull ;-)

  3. You are welcome, Its good to know that my post could be of some use for you.