framework.src.org.checkerframework.framework.test.TestSuite Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of checker Show documentation
Show all versions of checker Show documentation
The Checker Framework enhances Java’s type system to
make it more powerful and useful. This lets software developers
detect and prevent errors in their Java programs.
The Checker Framework includes compiler plug-ins ("checkers")
that find bugs or verify their absence. It also permits you to
write your own compiler plug-ins.
package org.checkerframework.framework.test;
import org.junit.runner.Runner;
import org.junit.runner.notification.RunNotifier;
import org.junit.runners.BlockJUnit4ClassRunner;
import org.junit.runners.Parameterized.Parameters;
import org.junit.runners.Suite;
import org.junit.runners.model.FrameworkMethod;
import org.junit.runners.model.InitializationError;
import org.junit.runners.model.Statement;
import org.junit.runners.model.TestClass;
import java.io.File;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import java.lang.reflect.Modifier;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
/**
*
* TestSuite runs a test class once for each set of parameters returned by its method marked with {@code @Parameters}
* To use:
* Annotated your test class with {@code @RunWith(TestSuite.class)}
* Create a parameters method by annotating a public static method with {@code @Parameters}. This method
* must return either a {@code List} where each element of the list is a Java file to test against
* OR a {@code String []} where each String in the array is a directory in the tests directory.
*
*/
public class TestSuite extends Suite {
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
public @interface Name {}
private final ArrayList runners = new ArrayList();
@Override
protected List getChildren() {
return runners;
}
/**
* Only called reflectively. Do not use programmatically.
*/
public TestSuite(Class klass) throws Throwable {
super(klass, Collections.emptyList());
final TestClass testClass = getTestClass();
final Class javaTestClass = testClass.getJavaClass();
final List