use of org.junit.platform.launcher.Launcher in project mockito by mockito.
the class StrictnessTest method invokeTestClassAndRetrieveMethodResult.
private TestExecutionResult invokeTestClassAndRetrieveMethodResult(Class<?> clazz) {
LauncherDiscoveryRequest request = LauncherDiscoveryRequestBuilder.request().selectors(selectClass(clazz)).build();
Launcher launcher = LauncherFactory.create();
final TestExecutionResult[] result = new TestExecutionResult[1];
launcher.registerTestExecutionListeners(new TestExecutionListener() {
@Override
public void executionFinished(TestIdentifier testIdentifier, TestExecutionResult testExecutionResult) {
if (testIdentifier.getDisplayName().endsWith("()")) {
result[0] = testExecutionResult;
}
}
});
launcher.execute(request);
return result[0];
}
use of org.junit.platform.launcher.Launcher in project neo4j by neo4j.
the class ProfilerExtensionTest method execute.
private static void execute(Class<?> testClass, String testName, TestExecutionListener... testExecutionListeners) {
LauncherDiscoveryRequest discoveryRequest = LauncherDiscoveryRequestBuilder.request().selectors(selectMethod(testClass, testName)).configurationParameter(TEST_TOGGLE, "true").build();
Launcher launcher = LauncherFactory.create();
launcher.execute(discoveryRequest, testExecutionListeners);
}
use of org.junit.platform.launcher.Launcher in project spring-boot by spring-projects.
the class ModifiedClassPathExtension method runTest.
private void runTest(ClassLoader classLoader, String testClassName, String testMethodName) throws Throwable {
Class<?> testClass = classLoader.loadClass(testClassName);
Method testMethod = findMethod(testClass, testMethodName);
LauncherDiscoveryRequest request = LauncherDiscoveryRequestBuilder.request().selectors(DiscoverySelectors.selectMethod(testClass, testMethod)).build();
Launcher launcher = LauncherFactory.create();
TestPlan testPlan = launcher.discover(request);
SummaryGeneratingListener listener = new SummaryGeneratingListener();
launcher.registerTestExecutionListeners(listener);
launcher.execute(testPlan);
TestExecutionSummary summary = listener.getSummary();
if (!CollectionUtils.isEmpty(summary.getFailures())) {
throw summary.getFailures().get(0).getException();
}
}
use of org.junit.platform.launcher.Launcher in project spring-framework by spring-projects.
the class ParallelExecutionSpringExtensionTests method runTestsInParallel.
@RepeatedTest(10)
void runTestsInParallel() {
Launcher launcher = LauncherFactory.create();
SummaryGeneratingListener listener = new SummaryGeneratingListener();
launcher.registerTestExecutionListeners(listener);
LauncherDiscoveryRequest request = //
request().configurationParameter("junit.jupiter.conditions.deactivate", //
"org.junit.jupiter.engine.extension.DisabledCondition").configurationParameter("junit.jupiter.execution.parallel.enabled", //
"true").configurationParameter("junit.jupiter.execution.parallel.config.dynamic.factor", //
"10").selectors(//
selectClass(TestCase.class)).build();
launcher.execute(request);
assertThat(listener.getSummary().getTestsSucceededCount()).as("number of tests executed successfully").isEqualTo(NUM_TESTS);
}
use of org.junit.platform.launcher.Launcher in project narchy by automenta.
the class NARTestBenchmark method junit.
// @Benchmark
// @BenchmarkMode(Mode.AverageTime)
// @Fork(1)
// public void testY() {
// The.Compound.the = FastCompound.FAST_COMPOUND_BUILDER;
// // Param.SynchronousExecution_Max_CycleTime = 0.0001f;
//
// junit(testclass);
// }
static void junit(Class... testClasses) {
LauncherDiscoveryRequest request = LauncherDiscoveryRequestBuilder.request().selectors(// selectPackage("com.example.mytests"),
(ClassSelector[]) Util.map(DiscoverySelectors::selectClass, new ClassSelector[testClasses.length], testClasses)).build();
Launcher launcher = LauncherFactory.create();
// SummaryGeneratingListener listener = new SummaryGeneratingListener();
LoggingListener listener = LoggingListener.forJavaUtilLogging();
launcher.registerTestExecutionListeners(listener);
launcher.execute(request, listener);
// listener.getSummary().printTo(new PrintWriter(System.out));
}
Aggregations