Java 类org.junit.platform.engine.discovery.DiscoverySelectors 实例源码

项目:pitest-junit5-plugin    文件:JUnit5TestUnitFinder.java   
@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());
}
项目:allure-java    文件:AnnotationsTest.java   
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));
}
项目:allure-java    文件:AllureJunit5Test.java   
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));
}
项目:webtester2-core    文件:TestClassExecutor.java   
@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();
}