All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.testng.junit.JUnit4TestRecognizer Maven / Gradle / Ivy

There is a newer version: 7.10.2
Show newest version
package org.testng.junit;

import java.lang.annotation.Annotation;
import java.lang.reflect.Method;
import org.junit.runner.RunWith;

/** @author lukas */
public final class JUnit4TestRecognizer implements JUnitTestRecognizer {

  public JUnit4TestRecognizer() {}

  public boolean isTest(Class c) {
    for (Annotation an : c.getAnnotations()) {
      if (RunWith.class.isAssignableFrom(an.annotationType())) {
        return true;
      }
    }
    boolean haveTest = false;
    for (Method m : c.getMethods()) {
      for (Annotation a : m.getDeclaredAnnotations()) {
        if (org.junit.Test.class.isAssignableFrom(a.annotationType())) {
          haveTest = true;
          break;
        }
      }
    }
    return haveTest;
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy