use of org.junit.platform.engine.EngineExecutionListener in project junit5 by junit-team.
the class VintageTestEngine method execute.
@Override
public void execute(ExecutionRequest request) {
EngineExecutionListener engineExecutionListener = request.getEngineExecutionListener();
TestDescriptor engineTestDescriptor = request.getRootTestDescriptor();
engineExecutionListener.executionStarted(engineTestDescriptor);
RunnerExecutor runnerExecutor = new RunnerExecutor(engineExecutionListener);
executeAllChildren(runnerExecutor, engineTestDescriptor);
engineExecutionListener.executionFinished(engineTestDescriptor, successful());
}
use of org.junit.platform.engine.EngineExecutionListener in project junit5 by junit-team.
the class VintageTestEngineExecutionTests method reportsExecutionEventsAroundLifecycleMethods.
@Test
void reportsExecutionEventsAroundLifecycleMethods() {
Class<?> testClass = PlainJUnit4TestCaseWithLifecycleMethods.class;
PlainJUnit4TestCaseWithLifecycleMethods.EVENTS.clear();
EngineExecutionListener listener = new EngineExecutionListener() {
@Override
public void executionStarted(TestDescriptor testDescriptor) {
PlainJUnit4TestCaseWithLifecycleMethods.EVENTS.add("executionStarted:" + testDescriptor.getDisplayName());
}
@Override
public void executionFinished(TestDescriptor testDescriptor, TestExecutionResult testExecutionResult) {
PlainJUnit4TestCaseWithLifecycleMethods.EVENTS.add("executionFinished:" + testDescriptor.getDisplayName());
}
@Override
public void executionSkipped(TestDescriptor testDescriptor, String reason) {
PlainJUnit4TestCaseWithLifecycleMethods.EVENTS.add("executionSkipped:" + testDescriptor.getDisplayName());
}
@Override
public void dynamicTestRegistered(TestDescriptor testDescriptor) {
}
@Override
public void reportingEntryPublished(TestDescriptor testDescriptor, ReportEntry entry) {
}
};
execute(testClass, listener);
// @formatter:off
assertThat(PlainJUnit4TestCaseWithLifecycleMethods.EVENTS).containsExactly("executionStarted:JUnit Vintage", "executionStarted:" + testClass.getName(), "beforeClass", "executionStarted:failingTest", "before", "failingTest", "after", "executionFinished:failingTest", "executionSkipped:skippedTest", "executionStarted:succeedingTest", "before", "succeedingTest", "after", "executionFinished:succeedingTest", "afterClass", "executionFinished:" + testClass.getName(), "executionFinished:JUnit Vintage");
// @formatter:on
}
use of org.junit.platform.engine.EngineExecutionListener in project cucumber-jvm by cucumber.
the class CucumberTestEngineTest method createExecutionContext.
@Test
void createExecutionContext() {
EngineExecutionListener listener = new EmptyEngineExecutionListener();
ConfigurationParameters configuration = new EmptyConfigurationParameters();
EngineDiscoveryRequest discoveryRequest = new EmptyEngineDiscoveryRequest(configuration);
UniqueId id = UniqueId.forEngine(engine.getId());
TestDescriptor testDescriptor = engine.discover(discoveryRequest, id);
ExecutionRequest execution = new ExecutionRequest(testDescriptor, listener, configuration);
assertNotNull(engine.createExecutionContext(execution));
}
use of org.junit.platform.engine.EngineExecutionListener in project junit5 by junit-team.
the class JupiterEngineDescriptor method prepare.
@Override
public JupiterEngineExecutionContext prepare(JupiterEngineExecutionContext context) {
ExtensionRegistry extensionRegistry = createRegistryWithDefaultExtensions(context.getConfigurationParameters());
EngineExecutionListener executionListener = context.getExecutionListener();
ExtensionContext extensionContext = new JupiterEngineExtensionContext(executionListener, this, context.getConfigurationParameters());
// @formatter:off
return context.extend().withExtensionRegistry(extensionRegistry).withExtensionContext(extensionContext).build();
// @formatter:on
}
use of org.junit.platform.engine.EngineExecutionListener in project junit5 by junit-team.
the class ExtensionContextTests method reportEntriesArePublishedToExecutionContext.
@Test
@SuppressWarnings("resource")
void reportEntriesArePublishedToExecutionContext() {
ClassTestDescriptor classTestDescriptor = outerClassDescriptor(null);
EngineExecutionListener engineExecutionListener = Mockito.spy(EngineExecutionListener.class);
ExtensionContext extensionContext = new ClassExtensionContext(null, engineExecutionListener, classTestDescriptor, configParams, null);
Map<String, String> map1 = Collections.singletonMap("key", "value");
Map<String, String> map2 = Collections.singletonMap("other key", "other value");
extensionContext.publishReportEntry(map1);
extensionContext.publishReportEntry(map2);
extensionContext.publishReportEntry("3rd key", "third value");
ArgumentCaptor<ReportEntry> entryCaptor = ArgumentCaptor.forClass(ReportEntry.class);
Mockito.verify(engineExecutionListener, Mockito.times(3)).reportingEntryPublished(Mockito.eq(classTestDescriptor), entryCaptor.capture());
ReportEntry reportEntry1 = entryCaptor.getAllValues().get(0);
ReportEntry reportEntry2 = entryCaptor.getAllValues().get(1);
ReportEntry reportEntry3 = entryCaptor.getAllValues().get(2);
assertEquals(map1, reportEntry1.getKeyValuePairs());
assertEquals(map2, reportEntry2.getKeyValuePairs());
assertEquals("third value", reportEntry3.getKeyValuePairs().get("3rd key"));
}
Aggregations