After the configuration is successful, you need to start the test case!
Package com. CMC. controller;
Import javax. annotation. Resource;
Import org. junit. Test;
Import org. junit. runner. RunWith;
Import org. springframework. test. context. ContextConfiguration;
Import org. springframework. test. context. junit4.SpringJUnit4ClassRunner;
Import org. springframework. util. Assert;
Import com. CMC. controller. Hello;
@ RunWith (SpringJUnit4ClassRunner. class)
@ ContextConfiguration (locations = {"classpath: applicationContext. xml ",
"Classpath: mvc. xml "})
Public class JuniorTest
{
@ Resource
Private Hello;
@ Test
Public void start ()
{
Assert. notNull (hello );
System. out. println ("OK ");
}
}
@ RunWith (SpringJUnit4ClassRunner. class) specifies the springJunit test class
@ ContextConfiguration specifies the location of the spring configuration file