use of org.junit.runners.model.FrameworkMethod in project spring-framework by spring-projects.
the class SpringMethodRule method apply.
/**
* Apply <em>instance-level</em> and <em>method-level</em> features of
* the <em>Spring TestContext Framework</em> to the supplied {@code base}
* statement.
* <p>Specifically, this method invokes the
* {@link TestContextManager#prepareTestInstance prepareTestInstance()},
* {@link TestContextManager#beforeTestMethod beforeTestMethod()}, and
* {@link TestContextManager#afterTestMethod afterTestMethod()} methods
* on the {@code TestContextManager}, potentially with Spring timeouts
* and repetitions.
* <p>In addition, this method checks whether the test is enabled in
* the current execution environment. This prevents methods with a
* non-matching {@code @IfProfileValue} annotation from running altogether,
* even skipping the execution of {@code prepareTestInstance()} methods
* in {@code TestExecutionListeners}.
* @param base the base {@code Statement} that this rule should be applied to
* @param frameworkMethod the method which is about to be invoked on the test instance
* @param testInstance the current test instance
* @return a statement that wraps the supplied {@code base} with instance-level
* and method-level features of the Spring TestContext Framework
* @see #withBeforeTestMethodCallbacks
* @see #withAfterTestMethodCallbacks
* @see #withPotentialRepeat
* @see #withPotentialTimeout
* @see #withTestInstancePreparation
* @see #withProfileValueCheck
*/
@Override
public Statement apply(Statement base, FrameworkMethod frameworkMethod, Object testInstance) {
Method testMethod = frameworkMethod.getMethod();
if (logger.isDebugEnabled()) {
logger.debug("Applying SpringMethodRule to test method [" + testMethod + "]");
}
Class<?> testClass = testInstance.getClass();
validateSpringClassRuleConfiguration(testClass);
TestContextManager testContextManager = SpringClassRule.getTestContextManager(testClass);
Statement statement = base;
statement = withBeforeTestMethodCallbacks(statement, testMethod, testInstance, testContextManager);
statement = withAfterTestMethodCallbacks(statement, testMethod, testInstance, testContextManager);
statement = withTestInstancePreparation(statement, testInstance, testContextManager);
statement = withPotentialRepeat(statement, testMethod, testInstance);
statement = withPotentialTimeout(statement, testMethod, testInstance);
statement = withProfileValueCheck(statement, testMethod, testInstance);
return statement;
}
use of org.junit.runners.model.FrameworkMethod in project Ebselen by Ardesco.
the class SeleniumJUnitRunner method computeTestMethods.
@Override
protected List<FrameworkMethod> computeTestMethods() {
List<FrameworkMethod> classMethods = getTestClass().getAnnotatedMethods(SeleniumTestAnnotations.SeleniumTest.class);
SortedMap<Integer, FrameworkMethod> sortedTestMethodList = new TreeMap<Integer, FrameworkMethod>();
for (FrameworkMethod seleniumTest : classMethods) {
if (seleniumTest.getAnnotation(SeleniumTestAnnotations.Order.class) != null) {
sortedTestMethodList.put(seleniumTest.getAnnotation(SeleniumTestAnnotations.Order.class).value(), seleniumTest);
}
}
return new ArrayList<FrameworkMethod>(sortedTestMethodList.values());
}
use of org.junit.runners.model.FrameworkMethod in project robolectric by robolectric.
the class SandboxTestRunner method invokeBeforeClass.
private void invokeBeforeClass(final Class clazz) throws Throwable {
if (!loadedTestClasses.contains(clazz)) {
loadedTestClasses.add(clazz);
final TestClass testClass = new TestClass(clazz);
final List<FrameworkMethod> befores = testClass.getAnnotatedMethods(BeforeClass.class);
for (FrameworkMethod before : befores) {
before.invokeExplosively(null);
}
}
}
use of org.junit.runners.model.FrameworkMethod in project robolectric by robolectric.
the class RobolectricTestRunner method createClassLoaderConfig.
/**
* Create an {@link InstrumentationConfiguration} suitable for the provided {@link Config}.
*
* Custom TestRunner subclasses may wish to override this method to provide alternate configuration.
*
* @param config the merged configuration for the test that's about to run -- todo
* @return an {@link InstrumentationConfiguration}
* @deprecated Override {@link #createClassLoaderConfig(FrameworkMethod)} instead
*/
@Deprecated
@NotNull
public InstrumentationConfiguration createClassLoaderConfig(Config config) {
FrameworkMethod method = ((MethodPassThrough) config).method;
Builder builder = new InstrumentationConfiguration.Builder(super.createClassLoaderConfig(method));
AndroidConfigurer.configure(builder, getInterceptors());
AndroidConfigurer.withConfig(builder, config);
return builder.build();
}
use of org.junit.runners.model.FrameworkMethod in project randomizedtesting by randomizedtesting.
the class RandomizedRunner method wrapMethodRules.
/**
* Wrap the given statement in any declared MethodRules (old style rules).
*/
@SuppressWarnings("deprecation")
private Statement wrapMethodRules(Statement s, TestCandidate c, Object instance) {
FrameworkMethod fm = new FrameworkMethod(c.method);
// Old-style MethodRules first.
List<org.junit.rules.MethodRule> methodRules = getAnnotatedFieldValues(instance, Rule.class, org.junit.rules.MethodRule.class);
for (org.junit.rules.MethodRule rule : methodRules) {
s = rule.apply(s, fm, instance);
}
// New-style TestRule next.
List<TestRule> testRules = getAnnotatedFieldValues(instance, Rule.class, TestRule.class);
for (TestRule rule : testRules) {
s = rule.apply(s, c.description);
}
return s;
}
Aggregations