Java源码示例:org.junit.platform.engine.DiscoverySelector

示例1
@Override
@SuppressWarnings("unchecked") // compatibility is explicitly checked
public <T extends DiscoverySelector> List<T> getSelectorsByType(Class<T> selectorType) {
    if (ClasspathRootSelector.class.equals(selectorType)) {
        return (List<T>) createClasspathRootSelectors(classpathRootsToDiscover);
    }
    if (PackageSelector.class.equals(selectorType)) {
        return (List<T>) createPackageSelectors(packagesToDiscover);
    }
    if (ClassSelector.class.equals(selectorType)) {
        return (List<T>) createClassSelectors(classesToDiscover);
    }
    if (MethodSelector.class.equals(selectorType)) {
        return (List<T>) createMethodSelectors(methodsToDiscover);
    }
    if (FieldSelector.class.equals(selectorType)) {
        return (List<T>) createFieldSelectors(fieldsToDiscover);
    }
    if (UniqueIdSelector.class.equals(selectorType)) {
        return (List<T>) createUniqueIdSelectors(idsToDiscover);
    }
    return emptyList();
}
 
示例2
private DiscoverySelector testSelector(String testClassName) {

            if (testClassName.contains("#")) {
                return selectMethod(testClassName);
            }

            return selectClass(testClassName);
        }
 
示例3
@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();
}