use of org.junit.jupiter.engine.config.DefaultJupiterConfiguration in project junit5 by junit-team.
the class JupiterTestEngine method discover.
@Override
public TestDescriptor discover(EngineDiscoveryRequest discoveryRequest, UniqueId uniqueId) {
JupiterConfiguration configuration = new CachingJupiterConfiguration(new DefaultJupiterConfiguration(discoveryRequest.getConfigurationParameters()));
JupiterEngineDescriptor engineDescriptor = new JupiterEngineDescriptor(uniqueId, configuration);
new DiscoverySelectorResolver().resolveSelectors(discoveryRequest, engineDescriptor);
return engineDescriptor;
}
use of org.junit.jupiter.engine.config.DefaultJupiterConfiguration in project junit5 by junit-team.
the class ExtensionContextTests method configurationParameter.
@TestFactory
Stream<DynamicTest> configurationParameter() throws Exception {
JupiterConfiguration echo = new DefaultJupiterConfiguration(new EchoParameters());
String key = "123";
Optional<String> expected = Optional.of(key);
UniqueId engineUniqueId = UniqueId.parse("[engine:junit-jupiter]");
JupiterEngineDescriptor engineDescriptor = new JupiterEngineDescriptor(engineUniqueId, configuration);
UniqueId classUniqueId = UniqueId.parse("[engine:junit-jupiter]/[class:MyClass]");
ClassTestDescriptor classTestDescriptor = new ClassTestDescriptor(classUniqueId, getClass(), configuration);
Method method = getClass().getDeclaredMethod("configurationParameter");
UniqueId methodUniqueId = UniqueId.parse("[engine:junit-jupiter]/[class:MyClass]/[method:myMethod]");
TestMethodTestDescriptor methodTestDescriptor = new TestMethodTestDescriptor(methodUniqueId, getClass(), method, configuration);
return //
Stream.of(//
(ExtensionContext) new JupiterEngineExtensionContext(null, engineDescriptor, echo, null), //
new ClassExtensionContext(null, null, classTestDescriptor, echo, null, null), //
new MethodExtensionContext(null, null, methodTestDescriptor, echo, null, null)).map(context -> dynamicTest(context.getClass().getSimpleName(), () -> assertEquals(expected, context.getConfigurationParameter(key))));
}
use of org.junit.jupiter.engine.config.DefaultJupiterConfiguration in project junit5 by junit-team.
the class TestInstanceLifecycleUtilsTests method getTestInstanceLifecycleWithConfigParamSet.
@Test
void getTestInstanceLifecycleWithConfigParamSet() {
ConfigurationParameters configParams = mock(ConfigurationParameters.class);
when(configParams.get(KEY)).thenReturn(Optional.of(PER_CLASS.name().toLowerCase()));
Lifecycle lifecycle = getTestInstanceLifecycle(getClass(), new DefaultJupiterConfiguration(configParams));
assertThat(lifecycle).isEqualTo(PER_CLASS);
}
use of org.junit.jupiter.engine.config.DefaultJupiterConfiguration in project junit5 by junit-team.
the class TestInstanceLifecycleUtilsTests method getTestInstanceLifecycleFromMetaAnnotationWithNoConfigParamSet.
@Test
void getTestInstanceLifecycleFromMetaAnnotationWithNoConfigParamSet() {
Class<?> testClass = BaseMetaAnnotatedTestCase.class;
Lifecycle lifecycle = getTestInstanceLifecycle(testClass, new DefaultJupiterConfiguration(mock(ConfigurationParameters.class)));
assertThat(lifecycle).isEqualTo(PER_CLASS);
}
use of org.junit.jupiter.engine.config.DefaultJupiterConfiguration in project junit5 by junit-team.
the class TestInstanceLifecycleUtilsTests method getTestInstanceLifecyclePreconditions.
@Test
void getTestInstanceLifecyclePreconditions() {
PreconditionViolationException exception = assertThrows(PreconditionViolationException.class, () -> getTestInstanceLifecycle(null, new DefaultJupiterConfiguration(mock(ConfigurationParameters.class))));
assertThat(exception).hasMessage("testClass must not be null");
exception = assertThrows(PreconditionViolationException.class, () -> getTestInstanceLifecycle(getClass(), null));
assertThat(exception).hasMessage("configuration must not be null");
}
Aggregations