use of org.junit.runners.model.FrameworkMethod in project pact-jvm by DiUS.
the class InteractionRunner method withStateChanges.
protected Statement withStateChanges(final Interaction interaction, final Object target, final Statement statement) {
if (StringUtils.isNotEmpty(interaction.getProviderState())) {
final String state = interaction.getProviderState();
final List<FrameworkMethod> onStateChange = new ArrayList<FrameworkMethod>();
for (FrameworkMethod ann : testClass.getAnnotatedMethods(State.class)) {
for (String annotationState : ann.getAnnotation(State.class).value()) {
if (annotationState.equalsIgnoreCase(state)) {
onStateChange.add(ann);
break;
}
}
}
if (onStateChange.isEmpty()) {
return new Fail(new MissingStateChangeMethod("MissingStateChangeMethod: Did not find a test class method annotated with @State(\"" + state + "\")"));
}
return new RunBefores(statement, onStateChange, target);
} else {
return statement;
}
}
use of org.junit.runners.model.FrameworkMethod in project geode by apache.
the class PerTestClassLoaderRunner method methodBlock.
@Override
protected Statement methodBlock(FrameworkMethod method) {
FrameworkMethod newMethod = null;
try {
// Need the class from the custom loader now, so lets load the class.
loadClassesWithCustomClassLoader();
// The method as parameter is from the original class and thus not found in our
// class loaded by the custom name (reflection is class loader sensitive)
// So find the same method but now in the class from the class Loader.
Method methodFromNewlyLoadedClass = testClassFromClassLoader.getJavaClass().getMethod(method.getName());
newMethod = new FrameworkMethod(methodFromNewlyLoadedClass);
} catch (ClassNotFoundException e) {
// Show any problem nicely as a JUnit Test failure.
return new Fail(e);
} catch (SecurityException e) {
return new Fail(e);
} catch (NoSuchMethodException e) {
return new Fail(e);
}
// We can carry out the normal JUnit functionality with our newly discovered method now.
return super.methodBlock(newMethod);
}
use of org.junit.runners.model.FrameworkMethod in project sling by apache.
the class PerformanceRunner method validatePerformanceTestsExecutionStrategy.
private void validatePerformanceTestsExecutionStrategy(List<Throwable> errors) {
for (FrameworkMethod method : getTestClass().getAnnotatedMethods(PerformanceTest.class)) {
int warmUpInvocations = getWarmUpInvocations(method);
int warmUpTime = getWarmUpTime(method);
if (warmUpInvocations <= 0 && warmUpTime <= 0) {
errors.add(new Error("Method " + method.getName() + "() should provide a valid warmUpInvocations or warmUpTime"));
}
if (warmUpInvocations > 0 && warmUpTime > 0) {
errors.add(new Error("Method " + method.getName() + "() provides both a valid warmUpInvocations and a warmUpTime"));
}
int runInvocations = getRunInvocations(method);
int runTime = getRunTime(method);
if (runInvocations <= 0 && runTime <= 0) {
errors.add(new Error("Method " + method.getName() + "() should provide a valid runInvocations or runTime"));
}
if (runInvocations > 0 && runTime > 0) {
errors.add(new Error("Method " + method.getName() + "() provides both a valid runInvocations or runTime"));
}
}
}
Aggregations