use of org.junit.platform.engine.TestEngine in project junit5 by junit-team.
the class TestEngineTests method defaults.
@Test
void defaults() {
TestEngine engine = new DefaultEngine();
assertEquals(Optional.empty(), engine.getGroupId());
assertEquals(Optional.empty(), engine.getArtifactId());
assertEquals(Optional.of("DEVELOPMENT"), engine.getVersion());
}
use of org.junit.platform.engine.TestEngine in project junit5 by junit-team.
the class EngineDiscoveryOrchestrator method discoverSafely.
private Map<TestEngine, TestDescriptor> discoverSafely(LauncherDiscoveryRequest request, Phase phase, LauncherDiscoveryListener listener, Function<String, UniqueId> uniqueIdCreator) {
Map<TestEngine, TestDescriptor> testEngineDescriptors = new LinkedHashMap<>();
for (TestEngine testEngine : this.testEngines) {
boolean engineIsExcluded = //
request.getEngineFilters().stream().map(//
engineFilter -> engineFilter.apply(testEngine)).anyMatch(FilterResult::excluded);
if (engineIsExcluded) {
logger.debug(() -> String.format("Test discovery for engine '%s' was skipped due to an EngineFilter in %s phase.", testEngine.getId(), phase));
continue;
}
logger.debug(() -> String.format("Discovering tests during Launcher %s phase in engine '%s'.", phase, testEngine.getId()));
TestDescriptor rootDescriptor = discoverEngineRoot(testEngine, request, listener, uniqueIdCreator);
testEngineDescriptors.put(testEngine, rootDescriptor);
}
List<PostDiscoveryFilter> filters = new LinkedList<>(postDiscoveryFilters);
filters.addAll(request.getPostDiscoveryFilters());
applyPostDiscoveryFilters(testEngineDescriptors, filters);
prune(testEngineDescriptors);
return testEngineDescriptors;
}
use of org.junit.platform.engine.TestEngine in project junit5 by junit-team.
the class EngineExecutionOrchestrator method execute.
/**
* Executes tests for the supplied {@linkplain LauncherDiscoveryResult
* discovery results} and notifies the supplied {@linkplain
* EngineExecutionListener listener} of execution events.
*/
public void execute(LauncherDiscoveryResult discoveryResult, EngineExecutionListener listener) {
for (TestEngine testEngine : discoveryResult.getTestEngines()) {
TestDescriptor engineDescriptor = discoveryResult.getEngineTestDescriptor(testEngine);
if (engineDescriptor instanceof EngineDiscoveryErrorDescriptor) {
listener.executionStarted(engineDescriptor);
listener.executionFinished(engineDescriptor, TestExecutionResult.failed(((EngineDiscoveryErrorDescriptor) engineDescriptor).getCause()));
} else {
execute(engineDescriptor, listener, discoveryResult.getConfigurationParameters(), testEngine);
}
}
}
use of org.junit.platform.engine.TestEngine in project junit5 by junit-team.
the class LauncherConfigTests method preconditions.
@Test
void preconditions() {
assertThrows(PreconditionViolationException.class, () -> LauncherConfig.builder().addTestEngines((TestEngine[]) null));
assertThrows(PreconditionViolationException.class, () -> LauncherConfig.builder().addTestExecutionListeners((TestExecutionListener[]) null));
TestEngine engine = new TestEngineStub();
var listener = new TestExecutionListener() {
};
assertThrows(PreconditionViolationException.class, () -> LauncherConfig.builder().addTestEngines(engine, engine, null));
assertThrows(PreconditionViolationException.class, () -> LauncherConfig.builder().addTestExecutionListeners(listener, listener, null));
}
Aggregations