下面列出了org.springframework.test.context.TestContext#publishEvent ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
/**
* Publish a {@link BeforeTestClassEvent} to the {@code ApplicationContext}
* for the supplied {@link TestContext}.
*/
@Override
public void beforeTestClass(TestContext testContext) {
testContext.publishEvent(BeforeTestClassEvent::new);
}
/**
* Publish a {@link PrepareTestInstanceEvent} to the {@code ApplicationContext}
* for the supplied {@link TestContext}.
*/
@Override
public void prepareTestInstance(TestContext testContext) {
testContext.publishEvent(PrepareTestInstanceEvent::new);
}
/**
* Publish a {@link BeforeTestMethodEvent} to the {@code ApplicationContext}
* for the supplied {@link TestContext}.
*/
@Override
public void beforeTestMethod(TestContext testContext) {
testContext.publishEvent(BeforeTestMethodEvent::new);
}
/**
* Publish a {@link BeforeTestExecutionEvent} to the {@code ApplicationContext}
* for the supplied {@link TestContext}.
*/
@Override
public void beforeTestExecution(TestContext testContext) {
testContext.publishEvent(BeforeTestExecutionEvent::new);
}
/**
* Publish an {@link AfterTestExecutionEvent} to the {@code ApplicationContext}
* for the supplied {@link TestContext}.
*/
@Override
public void afterTestExecution(TestContext testContext) {
testContext.publishEvent(AfterTestExecutionEvent::new);
}
/**
* Publish an {@link AfterTestMethodEvent} to the {@code ApplicationContext}
* for the supplied {@link TestContext}.
*/
@Override
public void afterTestMethod(TestContext testContext) {
testContext.publishEvent(AfterTestMethodEvent::new);
}
/**
* Publish an {@link AfterTestClassEvent} to the {@code ApplicationContext}
* for the supplied {@link TestContext}.
*/
@Override
public void afterTestClass(TestContext testContext) {
testContext.publishEvent(AfterTestClassEvent::new);
}
@Override
public void beforeTestExecution(TestContext testContext) throws Exception {
testContext.publishEvent(tc -> new CustomEvent(tc.getTestClass(), tc.getTestMethod()));
}