use of org.junit.runners.model.FrameworkMethod in project sling by apache.
the class RunAfters method evaluate.
@Override
public void evaluate() throws Throwable {
List<Throwable> errors = new ArrayList<Throwable>();
try {
next.evaluate();
} catch (Throwable e) {
errors.add(e);
} finally {
for (FrameworkMethod each : afters) {
try {
each.invokeExplosively(target);
} catch (Throwable e) {
errors.add(e);
}
}
}
MultipleFailureException.assertEmpty(errors);
}
use of org.junit.runners.model.FrameworkMethod in project sling by apache.
the class PerformanceRunner method readListenersFromStaticMethods.
private List<Listener> readListenersFromStaticMethods() throws Throwable {
List<Listener> listeners = new ArrayList<Listener>();
for (FrameworkMethod method : getTestClass().getAnnotatedMethods(Listen.class)) {
Listener listener = (Listener) method.invokeExplosively(null);
if (listener == null) {
throw new IllegalArgumentException("Method " + method.getName() + "() should not return null");
}
listeners.add(listener);
}
return listeners;
}
use of org.junit.runners.model.FrameworkMethod in project java-crud-api by kolchagov.
the class OrderedTestRunner method computeTestMethods.
/*
* (non-Javadoc)
*
* @see org.junit.runners.BlockJUnit4ClassRunner#computeTestMethods()
*/
@Override
protected List<FrameworkMethod> computeTestMethods() {
// get all methods to be tested
List<FrameworkMethod> toSort = super.computeTestMethods();
if (toSort.isEmpty())
return toSort;
// a map containing <line_number, method>
final Map<Integer, FrameworkMethod> testMethods = new TreeMap<>();
// check that all methods here are declared in the same class, we don't
// deal with test methods from superclasses that haven't been overridden
Class<?> clazz = getDeclaringClass(toSort);
if (clazz == null) {
// fail explicitly
System.err.println("OrderedTestRunner can only run test classes that" + " don't have test methods inherited from superclasses");
return Collections.emptyList();
}
// use Javassist to figure out line numbers for methods
ClassPool pool = ClassPool.getDefault();
try {
CtClass cc = pool.get(clazz.getName());
// all methods in toSort are declared in the same class, we checked
for (FrameworkMethod m : toSort) {
String methodName = m.getName();
CtMethod method = cc.getDeclaredMethod(methodName);
testMethods.put(method.getMethodInfo().getLineNumber(0), m);
}
} catch (NotFoundException e) {
e.printStackTrace();
}
return new ArrayList<>(testMethods.values());
}
use of org.junit.runners.model.FrameworkMethod in project tomee by apache.
the class SingleApplicationComposerRunner method rules.
@Override
protected List<MethodRule> rules(final Object test) {
final List<MethodRule> rules = super.rules(test);
rules.add(new MethodRule() {
@Override
public Statement apply(final Statement base, final FrameworkMethod method, final Object target) {
return new Statement() {
@Override
public void evaluate() throws Throwable {
start(getTestClass().getJavaClass());
composerInject(target);
base.evaluate();
}
};
}
});
return rules;
}
use of org.junit.runners.model.FrameworkMethod in project tomee by apache.
the class ApplicationComposer method rules.
@Override
protected List<MethodRule> rules(final Object test) {
final List<MethodRule> rules = super.rules(test);
rules.add(new MethodRule() {
public Statement apply(final Statement base, final FrameworkMethod method, final Object target) {
return new DeployApplication(target, base, delegate);
}
});
return rules;
}
Aggregations