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
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<scope>test</scope>
<version>3.1.2.RELEASE</version>
</dependency>
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
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.5</version>
</dependency>