Junit unit testing
Spring integration configuration junit
- Introducing the junit JAR integrated spring (coordinates)
- Replace the original main method to use a note Junit provided: @RunWith
- Inform the runner spring, spring and ioc creation is based on xml or annotation: @ContextConfiguration
- locations: Specifies the xml file location
- Specify the location of classes where class notes
- When using spring 5.x version, requiring junit jar package must be 4.12 or above
Examples
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = { "classpath*:bean.xml" })
public class Test1 {
@Autowired
MyService myService = null;
@Test
public void test(){
myService.findAll();
}
}