use of org.junit.jupiter.engine.config.DefaultJupiterConfiguration in project junit5 by junit-team.
the class TestInstanceLifecycleUtilsTests method getTestInstanceLifecycleWithNoConfigParamSet.
@Test
void getTestInstanceLifecycleWithNoConfigParamSet() {
Lifecycle lifecycle = getTestInstanceLifecycle(getClass(), new DefaultJupiterConfiguration(mock(ConfigurationParameters.class)));
assertThat(lifecycle).isEqualTo(PER_METHOD);
}
use of org.junit.jupiter.engine.config.DefaultJupiterConfiguration in project graylog2-server by Graylog2.
the class ContainerMatrixTestEngine method discover.
@Override
public TestDescriptor discover(EngineDiscoveryRequest discoveryRequest, UniqueId uniqueId) {
JupiterConfiguration configuration = new CachingJupiterConfiguration(new DefaultJupiterConfiguration(discoveryRequest.getConfigurationParameters()));
final ContainerMatrixEngineDescriptor engineDescriptor = new ContainerMatrixEngineDescriptor(uniqueId, "Graylog Container Matrix Tests", configuration);
Reflections reflections = new Reflections("org.graylog", "org.graylog2");
final Set<Class<?>> annotated = reflections.getTypesAnnotatedWith(ContainerMatrixTestsConfiguration.class);
final Set<Integer> extraPorts = getExtraPorts(annotated);
final List<URL> mongoDBFixtures = getMongoDBFixtures(annotated);
if (testAgainstRunningESMongoDB()) {
// if you test from inside an IDE against running containers
ContainerMatrixTestsDescriptor testsDescriptor = new ContainerMatrixTestWithRunningESMongoTestsDescriptor(engineDescriptor, extraPorts, mongoDBFixtures);
new ContainerMatrixTestsDiscoverySelectorResolver(engineDescriptor).resolveSelectors(discoveryRequest, testsDescriptor);
engineDescriptor.addChild(testsDescriptor);
} else {
// for full tests, create all combinations of tests. First differentiate for maven builds.
getMavenProjectDirProvider(annotated).forEach(mavenProjectDirProvider -> getPluginJarsProvider(annotated).forEach(pluginJarsProvider -> {
MavenProjectDirProvider mpdp = instantiateFactory(mavenProjectDirProvider);
PluginJarsProvider pjp = instantiateFactory(pluginJarsProvider);
// now add all grouped tests for Lifecycle.VM
getSearchServerVersions(annotated).stream().map(SearchServer::getSearchVersion).forEach(searchVersion -> getMongoVersions(annotated).forEach(mongoVersion -> {
ContainerMatrixTestsDescriptor testsDescriptor = new ContainerMatrixTestsDescriptor(engineDescriptor, Lifecycle.VM, mavenProjectDirProvider, mpdp.getUniqueId(), pluginJarsProvider, pjp.getUniqueId(), searchVersion, mongoVersion, extraPorts, mongoDBFixtures);
new ContainerMatrixTestsDiscoverySelectorResolver(engineDescriptor).resolveSelectors(discoveryRequest, testsDescriptor);
engineDescriptor.addChild(testsDescriptor);
}));
// add separate test classes (Lifecycle.CLASS)
getSearchServerVersions(annotated).stream().map(SearchServer::getSearchVersion).forEach(esVersion -> getMongoVersions(annotated).forEach(mongoVersion -> {
ContainerMatrixTestsDescriptor testsDescriptor = new ContainerMatrixTestsDescriptor(engineDescriptor, Lifecycle.CLASS, mavenProjectDirProvider, mpdp.getUniqueId(), pluginJarsProvider, pjp.getUniqueId(), esVersion, mongoVersion, extraPorts, new ArrayList<>());
new ContainerMatrixTestsDiscoverySelectorResolver(engineDescriptor).resolveSelectors(discoveryRequest, testsDescriptor);
engineDescriptor.addChild(testsDescriptor);
}));
}));
}
return engineDescriptor;
}
use of org.junit.jupiter.engine.config.DefaultJupiterConfiguration in project junit5 by junit-team.
the class TestInstanceLifecycleUtilsTests method getTestInstanceLifecycleFromSpecializedClassWithNoConfigParamSet.
@Test
void getTestInstanceLifecycleFromSpecializedClassWithNoConfigParamSet() {
Class<?> testClass = SpecializedTestCase.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 getTestInstanceLifecycleWithLocalConfigThatOverridesCustomDefaultSetViaConfigParam.
@Test
void getTestInstanceLifecycleWithLocalConfigThatOverridesCustomDefaultSetViaConfigParam() {
ConfigurationParameters configParams = mock(ConfigurationParameters.class);
when(configParams.get(KEY)).thenReturn(Optional.of(PER_CLASS.name().toLowerCase()));
Lifecycle lifecycle = getTestInstanceLifecycle(TestCase.class, new DefaultJupiterConfiguration(configParams));
assertThat(lifecycle).isEqualTo(PER_METHOD);
}
Aggregations