@Override public List<TestUnit> findTestUnits(Class<?> clazz) { TestPlan testPlan = launcher.discover(LauncherDiscoveryRequestBuilder .request() .selectors(DiscoverySelectors.selectClass(clazz)) .build()); return testPlan.getRoots() .stream() .map(testPlan::getDescendants) .flatMap(Set::stream) .filter(testIdentifier -> testIdentifier.getSource().isPresent()) .filter(testIdentifier -> testIdentifier.getSource().get() instanceof MethodSource) .filter(testIdentifier -> ((MethodSource) testIdentifier.getSource().get()).getClassName().equals(clazz.getName())) .map(testIdentifier -> new JUnit5TestUnit(testIdentifier)) .collect(toList()); }
private void runClasses(Class<?>... classes) { final ClassSelector[] classSelectors = Stream.of(classes) .map(DiscoverySelectors::selectClass) .toArray(ClassSelector[]::new); final LauncherDiscoveryRequest request = LauncherDiscoveryRequestBuilder.request() .selectors(classSelectors) .build(); AllureJunit5AnnotationProcessor.setLifecycle(lifecycle); final Launcher launcher = LauncherFactory.create(); launcher.execute(request, new AllureJunit5(lifecycle)); }
private void runClasses(Class<?>... classes) { final ClassSelector[] classSelectors = Stream.of(classes) .map(DiscoverySelectors::selectClass) .toArray(ClassSelector[]::new); final LauncherDiscoveryRequest request = LauncherDiscoveryRequestBuilder.request() .selectors(classSelectors) .build(); final Launcher launcher = LauncherFactory.create(); launcher.execute(request, new AllureJunit5(lifecycle)); }
@Override @SuppressWarnings("unchecked") public <T extends DiscoverySelector> List<T> getSelectorsByType(Class<T> selectorType) { if (ClassSelector.class.equals(selectorType)) { List<T> list = new ArrayList<>(); list.add(( T ) DiscoverySelectors.selectClass(testClass)); return list; } return Collections.emptyList(); }