What is the difference between SpringJUnit4ClassRunner and SpringRunner

SpringRunner is an alias for the SpringJUnit4ClassRunner. @RunWith(SpringRunner.class) tells JUnit to run using Spring’s testing support. SpringRunner is the new name for SpringJUnit4ClassRunner, it’s just a bit easier on the eye. SpringRunner is only available after spring-test 4.3. SpringRunner class extends SpringJUnit4ClassRunner.   Read the doc source code package org.springframework.test.context.junit4; import org.junit.runners.model.InitializationError; public final class SpringRunner extends SpringJUnit4ClassRunner Read more…

@RunWith(SpringJUnit4ClassRunner.class)

In order for the unit test to run a batch job, the framework must load the job’s ApplicationContext. Two annotations are used to trigger this: @RunWith(SpringJUnit4ClassRunner.class): Indicates that the class should use Spring’s JUnit facilities. @ContextConfiguration(locations = {…}): Indicates which XML files contain the ApplicationContext. For example: import org.junit.Test; import Read more…