org.junit.platform.launcher.TestPlan Java Examples
The following examples show how to use
org.junit.platform.launcher.TestPlan.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AllureJunitPlatform.java From allure-java with Apache License 2.0 | 6 votes |
@Override public void executionSkipped(final TestIdentifier testIdentifier, final String reason) { // skip root if (!testIdentifier.getParentId().isPresent()) { return; } final TestPlan testPlan = testPlanStorage.get(); if (Objects.isNull(testPlan)) { return; } reportNested( testPlan, testIdentifier, SKIPPED, new StatusDetails().setMessage(reason), new HashSet<>() ); }
Example #2
Source File: AllureJunitPlatform.java From allure-java with Apache License 2.0 | 6 votes |
private void stopTestContainer(final TestIdentifier testIdentifier) { final Optional<String> maybeUuid = containers.get(testIdentifier); if (!maybeUuid.isPresent()) { return; } final String uuid = maybeUuid.get(); final TestPlan context = testPlanStorage.get(); final Set<String> children = Optional.ofNullable(context) .map(tp -> tp.getDescendants(testIdentifier)) .orElseGet(Collections::emptySet) .stream() .filter(TestIdentifier::isTest) .map(tests::get) .filter(Optional::isPresent) .map(Optional::get) .collect(Collectors.toCollection(HashSet::new)); if (testIdentifier.isTest()) { tests.get(testIdentifier).ifPresent(children::add); } getLifecycle().updateTestContainer(uuid, container -> container.setChildren(children)); getLifecycle().stopTestContainer(uuid); getLifecycle().writeTestContainer(uuid); }
Example #3
Source File: SummaryPrintingTestListener.java From sbt-jupiter-interface with Apache License 2.0 | 6 votes |
@Override public void testPlanExecutionFinished(TestPlan testPlan) { TestExecutionSummary summary = getSummary(); long testRunDuration = System.currentTimeMillis() - summary.getTimeStarted(); long totalFailureCount = summary.getTotalFailureCount(); long testsSkippedCount = summary.getTestsSkippedCount(); long totalTestsFound = summary.getTestsFoundCount(); Color ignoreColor = testsSkippedCount > 0 ? colorTheme.ignoreCount() : colorTheme.info(); Color errorColor = totalFailureCount > 0 ? colorTheme.errorCount() : colorTheme.info(); debugOrInfo("" + colorTheme.info().format("Test run finished: ") + errorColor.format(totalFailureCount + " failed") + colorTheme.info().format(", ") + ignoreColor.format(testsSkippedCount + " ignored") + colorTheme.info().format(", ") + colorTheme.info().format(totalTestsFound + " total, ") + colorTheme.info().format(testRunDuration/1000.0 + "s") ); }
Example #4
Source File: TestHelper.java From sbt-jupiter-interface with Apache License 2.0 | 5 votes |
/** * Creates a new test plan helper for a specific test class. * * @param testClass The name of the test class. * @return A new test helper instance. */ public static TestHelper of(String testClass) { LauncherDiscoveryRequest request = LauncherDiscoveryRequestBuilder.request() .selectors(selectClass(testClass)) .build(); final TestPlan testPlan = LauncherFactory.create().discover(request); return new TestHelper(testPlan); }
Example #5
Source File: RunJUnit5TestsFromJava.java From tutorials with MIT License | 5 votes |
public void runAll() { LauncherDiscoveryRequest request = LauncherDiscoveryRequestBuilder .request() .selectors(selectPackage("com.baeldung.runfromjava")) .filters(includeClassNamePatterns(".*Test")) .build(); Launcher launcher = LauncherFactory.create(); TestPlan testPlan = launcher.discover(request); launcher.registerTestExecutionListeners(listener); launcher.execute(request); }
Example #6
Source File: RunJUnit5TestsFromJava.java From tutorials with MIT License | 5 votes |
public void runOne() { LauncherDiscoveryRequest request = LauncherDiscoveryRequestBuilder .request() .selectors(selectClass(FirstUnitTest.class)) .build(); Launcher launcher = LauncherFactory.create(); TestPlan testPlan = launcher.discover(request); launcher.registerTestExecutionListeners(listener); launcher.execute(request); }
Example #7
Source File: TestLauncher.java From tutorials with MIT License | 5 votes |
public static void main(String[] args) { //@formatter:off LauncherDiscoveryRequest request = LauncherDiscoveryRequestBuilder.request() .selectors(selectClass("com.baeldung.EmployeesUnitTest")) .configurationParameter("junit.conditions.deactivate", "com.baeldung.extensions.*") .configurationParameter("junit.jupiter.extensions.autodetection.enabled", "true") .build(); //@formatter:on TestPlan plan = LauncherFactory.create() .discover(request); Launcher launcher = LauncherFactory.create(); SummaryGeneratingListener summaryGeneratingListener = new SummaryGeneratingListener(); launcher.execute(request, new TestExecutionListener[] { summaryGeneratingListener }); launcher.execute(request); summaryGeneratingListener.getSummary() .printTo(new PrintWriter(System.out)); }
Example #8
Source File: JunitExecutionListener.java From enmasse with Apache License 2.0 | 5 votes |
@Override public void testPlanExecutionFinished(TestPlan testPlan) { var tags = TestInfo.getInstance().getTestRunTags(); if (tags != null && tags.size() == 1 && tags.get(0).equals(TestTag.FRAMEWORK)) { LOGGER.info("Running framework tests, no cleanup performed"); return; } final Environment env = Environment.getInstance(); if (!env.skipCleanup()) { // clean up resources LOGGER.info("Cleaning resources"); performCleanup(); } else { LOGGER.warn("Remove address spaces when test run finished - SKIPPED!"); } TimeMeasuringSystem.printAndSaveResults(); if (!(env.skipCleanup() || env.skipUninstall())) { // clean up infrastructure after resources LOGGER.info("Uninstalling infrastructure"); performInfraCleanup(); } }
Example #9
Source File: Configuration.java From sbt-jupiter-interface with Apache License 2.0 | 5 votes |
private List<TestIdentifier> getPath(TestPlan testPlan, TestIdentifier identifier) { List<TestIdentifier> result = new ArrayList<>(); do { result.add(identifier); identifier = testPlan.getParent(identifier).orElse(null); } while (null != identifier); Collections.reverse(result); return result; }
Example #10
Source File: JupiterTestCollector.java From sbt-jupiter-interface with Apache License 2.0 | 5 votes |
/** * Executes a JUnit Jupiter test discovery and collects the result. * * @return The result of discovered tests. */ private Result collectTests0() { Set<Path> classPathRoots = new HashSet<>(); classPathRoots.add(Paths.get(classDirectory.getAbsolutePath())); LauncherDiscoveryRequest request = LauncherDiscoveryRequestBuilder.request() .selectors(selectClasspathRoots(classPathRoots)) .selectors(selectDirectory(classDirectory)) .build(); TestPlan testPlan = LauncherFactory.create().discover(request); Result result = new Result(); for (TestIdentifier rootIdentifier : testPlan.getRoots()) { for (TestIdentifier identifier : testPlan.getChildren(rootIdentifier)) { String fqn = fullyQualifiedName(identifier); Selector selector = new SuiteSelector(); Item item = new Item(); item.fullyQualifiedClassName = fqn; item.selectors.add(selector); item.explicit = false; result.discoveredTests.add(item); } } return result; }
Example #11
Source File: AllureJunitPlatform.java From allure-java with Apache License 2.0 | 5 votes |
private void reportNested(final TestPlan testPlan, final TestIdentifier testIdentifier, final Status status, final StatusDetails statusDetails, final Set<TestIdentifier> visited) { final Set<TestIdentifier> children = testPlan.getChildren(testIdentifier); if (testIdentifier.isTest() || children.isEmpty()) { startTestCase(testIdentifier); stopTestCase(testIdentifier, status, statusDetails); } visited.add(testIdentifier); children.stream() .filter(id -> !visited.contains(id)) .forEach(child -> reportNested(testPlan, child, status, statusDetails, visited)); }
Example #12
Source File: LauncherApiExample.java From Mastering-Software-Testing-with-JUnit-5 with MIT License | 5 votes |
@SuppressWarnings("unused") public static void main(String[] args) { // Discover and filter tests LauncherDiscoveryRequest request = LauncherDiscoveryRequestBuilder .request() .selectors(selectPackage("io.github.bonigarcia"), selectClass(DummyTest.class)) .filters(includeClassNamePatterns(".*Test")).build(); Launcher launcher = LauncherFactory.create(); TestPlan plan = launcher.discover(request); // Executing tests TestExecutionListener listener = new SummaryGeneratingListener(); launcher.registerTestExecutionListeners(listener); launcher.execute(request, listener); }
Example #13
Source File: ZeroCodeTestReportJupiterListener.java From zerocode with Apache License 2.0 | 4 votes |
@Override public void testPlanExecutionFinished(TestPlan testPlan) { prepareResponseReport(logPrefixRelationshipId); buildReportAndPrintToFile(testDescription); }
Example #14
Source File: AllureJunitPlatform.java From allure-java with Apache License 2.0 | 4 votes |
@Override public void testPlanExecutionStarted(final TestPlan testPlan) { testPlanStorage.set(testPlan); }
Example #15
Source File: AllureJunitPlatform.java From allure-java with Apache License 2.0 | 4 votes |
@Override public void testPlanExecutionFinished(final TestPlan testPlan) { testPlanStorage.remove(); }
Example #16
Source File: ProgressListeners.java From jeka with Apache License 2.0 | 4 votes |
@Override public void testPlanExecutionFinished(TestPlan testPlan) { System.out.println(); }
Example #17
Source File: ProgressListeners.java From jeka with Apache License 2.0 | 4 votes |
@Override public void testPlanExecutionStarted(TestPlan testPlan) { long testCount = testPlan.countTestIdentifiers(testIdentifier -> testIdentifier.getType().isTest()); System.out.print("Launching " + testCount + " tests "); System.out.flush(); }
Example #18
Source File: ProgressListeners.java From jeka with Apache License 2.0 | 4 votes |
@Override public void testPlanExecutionFinished(TestPlan testPlan) { System.out.println(); }
Example #19
Source File: ProgressListeners.java From jeka with Apache License 2.0 | 4 votes |
@Override public void testPlanExecutionFinished(TestPlan testPlan) { silencer.silent(false); }
Example #20
Source File: ProgressListeners.java From jeka with Apache License 2.0 | 4 votes |
@Override public void testPlanExecutionStarted(TestPlan testPlan) { silencer.silent(true); }
Example #21
Source File: JunitPlatformDoer.java From jeka with Apache License 2.0 | 4 votes |
@Override public void testPlanExecutionFinished(TestPlan testPlan) { JkLog.JkState.restore(); }
Example #22
Source File: JunitPlatformDoer.java From jeka with Apache License 2.0 | 4 votes |
@Override public void testPlanExecutionStarted(TestPlan testPlan) { JkLog.JkState.save(); }
Example #23
Source File: Junit5Build.java From jeka with Apache License 2.0 | 4 votes |
@Override public void testPlanExecutionFinished(TestPlan testPlan) { System.out.println("Test plan " + testPlan + " has been executed ..."); }
Example #24
Source File: Junit5Build.java From jeka with Apache License 2.0 | 4 votes |
@Override public void testPlanExecutionStarted(TestPlan testPlan) { System.out.println("Test plan " + testPlan + " is being executed ..."); }
Example #25
Source File: ExecutionReportListener.java From junit5-extensions with MIT License | 4 votes |
@Override public void testPlanExecutionStarted(TestPlan testPlan) { executionReportBuilder = TestPlanExecutionReport.builder(testPlan); executionReportBuilder.addAllClassesToSkip(classesToSkip); classesToSkip.clear(); }
Example #26
Source File: JunitExecutionListener.java From enmasse with Apache License 2.0 | 4 votes |
@Override public void testPlanExecutionStarted(TestPlan testPlan) { TestInfo.getInstance().setTestPlan(testPlan); TestInfo.getInstance().printTestClasses(); }
Example #27
Source File: ZeroCodeTestReportJupiterListener.java From zerocode with Apache License 2.0 | 4 votes |
@Override public void testPlanExecutionStarted(TestPlan testPlan) { logPrefixRelationshipId = prepareRequestReport(testDescription); }
Example #28
Source File: ExecutionListener.java From strimzi-kafka-operator with Apache License 2.0 | 4 votes |
@Override public void testPlanExecutionFinished(TestPlan testPlan) { TimeMeasuringSystem.getInstance().printAndSaveResults(Environment.TEST_LOG_DIR); }
Example #29
Source File: TestHelper.java From sbt-jupiter-interface with Apache License 2.0 | 4 votes |
public TestPlan testPlan() { return testPlan; }
Example #30
Source File: LauncherApiExample.java From mastering-junit5 with Apache License 2.0 | 4 votes |
@SuppressWarnings("unused") public static void main(String[] args) { // Discover and filter tests LauncherDiscoveryRequest request = LauncherDiscoveryRequestBuilder .request() .selectors(selectPackage("io.github.bonigarcia"), selectClass(DummyTest.class)) .filters(includeClassNamePatterns(".*Test")).build(); Launcher launcher = LauncherFactory.create(); TestPlan plan = launcher.discover(request); // Executing tests TestExecutionListener listener = new SummaryGeneratingListener(); launcher.registerTestExecutionListeners(listener); launcher.execute(request, listener); }