/**
* @Package Name : ${PACKAG_NAME}
* @Author : 1766318593@qq.com
* @Creation Date : 2018年11月21日下午9:26
* @Function : todo
*/
public class systemExcetionListener implements TestExecutionListener {
@Override
public void beforeTestClass(TestContext testContext) throws Exception {
ConfigUtilAdapter.addConfiguration(new SystemConfiguration());
ConfigUtilAdapter.init();
}
@Override
public void prepareTestInstance(TestContext testContext) throws Exception {
}
@Override
public void beforeTestMethod(TestContext testContext) throws Exception {
}
@Override
public void afterTestMethod(TestContext testContext) throws Exception {
}
@Override
public void afterTestClass(TestContext testContext) throws Exception {
}
}
1 继承TestExecutionListener
2 加入到对应的test配置中
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = {
"classpath*:/config/spring/local/appcontext-*.xml",
// "classpath*:/config/spring/local/mvc-dispatcher-servlet.xml"
})
@Transactional
@ActiveProfiles("test")
@TestExecutionListeners({DependencyInjectionTestExecutionListener.class,
DirtiesContextTestExecutionListener.class,
TransactionalTestExecutionListener.class
})