• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 package org.testng.junit;
2 
3 import java.lang.annotation.Annotation;
4 import java.lang.reflect.Method;
5 import org.junit.runner.RunWith;
6 
7 /**
8  *
9  * @author lukas
10  */
11 public final class JUnit4TestRecognizer implements JUnitTestRecognizer {
12 
JUnit4TestRecognizer()13     public JUnit4TestRecognizer() {
14     }
15 
isTest(Class c)16     public boolean isTest(Class c) {
17         for (Annotation an: c.getAnnotations()) {
18             if (RunWith.class.isAssignableFrom(an.annotationType())) {
19                 return true;
20             }
21         }
22         boolean haveTest = false;
23         for (Method m : c.getMethods()) {
24             for (Annotation a : m.getDeclaredAnnotations()) {
25                 if (org.junit.Test.class.isAssignableFrom(a.annotationType())) {
26                     haveTest = true;
27                     break;
28                 }
29             }
30         }
31         return haveTest;
32     }
33 }
34