ImportOrg.junit.runner.RunWith;Importorg.springframework.test.context.ContextConfiguration;ImportOrg.springframework.test.context.TestPropertySource;Importorg.springframework.test.context.junit4.AbstractJUnit4SpringContextTests;ImportOrg.springframework.test.context.junit4.SpringJUnit4ClassRunner;/*** Created by JECYHW on 16-5-12.*/@RunWith (Springjunit4classrunner.class)//using spring to integrate JUnit test class tests@ContextConfiguration (locations = {//SPRING-MVC configuration file"File:src/main/resources/applicationcontext.xml"}) @TestPropertySource (Locations= {//The properties file used"File:src/main/resources/mongodb.properties", "File:src/main/resources/weixin.properties"})Abstract Public classBasetestextendsabstractjunit4springcontexttests {//all other test inherit basetest can be}
// a simple test class Public class extends basetest{ @Resource Eventdao Eventdao; @Test publicvoid list () { jsonutil.writeasstring (eventdao.list ());} }
SPRING-MVC JUnit Test