void (String[] args) { try { Launcher launcher = LauncherFactory.create(); ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); ClassNameFilter nameFilter; try { nameFilter = createClassNameFilter(classLoader); } catch (Throwable e) { e.printStackTrace(); System.exit(1); return; } System.out.println("Number of test engines: " + ServiceLoader.load(TestEngine.class).stream().count()); LauncherDiscoveryRequest discoveryRequest = LauncherDiscoveryRequestBuilder.request() .configurationParameter("junit.jupiter.extensions.autodetection.enabled", "true") .selectors(DiscoverySelectors.selectPackage("")) .filters(nameFilter, EngineFilter.excludeEngines(VintageTestDescriptor.ENGINE_ID)).build(); TestPlan testPlan = launcher.discover(discoveryRequest); if (testPlan.containsTests()) { launcher.execute(testPlan, new JUnit5TeamCityRunnerForTestAllSuite.TCExecutionListener()); } else { //see org.jetbrains.intellij.build.impl.TestingTasksImpl.NO_TESTS_ERROR System.exit(42); } } finally { System.exit(0); } }