Search in sources :

Example 1 with TestGroup

use of com.carrotsearch.randomizedtesting.annotations.TestGroup in project randomizedtesting by randomizedtesting.

the class GroupEvaluator method collectGroups.

private HashMap<Class<? extends Annotation>, TestGroupInfo> collectGroups(List<TestCandidate> testCandidates) {
    final HashMap<Class<? extends Annotation>, TestGroupInfo> groups = new HashMap<Class<? extends Annotation>, TestGroupInfo>();
    // Collect all groups declared on methods and instance classes.
    HashSet<Class<?>> clazzes = new HashSet<Class<?>>();
    HashSet<Annotation> annotations = new HashSet<Annotation>();
    for (TestCandidate c : testCandidates) {
        final Class<?> testClass = c.getTestClass();
        if (!clazzes.contains(testClass)) {
            clazzes.add(testClass);
            annotations.addAll(Arrays.asList(testClass.getAnnotations()));
        }
        annotations.addAll(Arrays.asList(c.method.getAnnotations()));
    }
    // Get TestGroup annotated annotations.
    for (Annotation ann : annotations) {
        Class<? extends Annotation> annType = ann.annotationType();
        if (!groups.containsKey(ann) && annType.isAnnotationPresent(TestGroup.class)) {
            groups.put(annType, new TestGroupInfo(annType));
        }
    }
    return groups;
}
Also used : HashMap(java.util.HashMap) TestCandidate(com.carrotsearch.randomizedtesting.RandomizedRunner.TestCandidate) TestGroup(com.carrotsearch.randomizedtesting.annotations.TestGroup) Annotation(java.lang.annotation.Annotation) HashSet(java.util.HashSet)

Aggregations

TestCandidate (com.carrotsearch.randomizedtesting.RandomizedRunner.TestCandidate)1 TestGroup (com.carrotsearch.randomizedtesting.annotations.TestGroup)1 Annotation (java.lang.annotation.Annotation)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1