org.junit.rules.MethodRule Java Examples

The following examples show how to use org.junit.rules.MethodRule. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: QuickPerfSpringRunner.java    From quickperf with Apache License 2.0 5 votes vote down vote up
@Override
protected List<MethodRule> rules(Object target) {
    if (SystemProperties.TEST_CODE_EXECUTING_IN_NEW_JVM.evaluate()) {
        return QUICK_PERF_SPRING_RUNNER_FOR_SPECIFIC_JVM.rules(target);
    }
    if(quickPerfFeaturesAreDisabled) {
        return springRunner.rules(target);
    }
    return super.rules(target);
}
 
Example #2
Source File: QuickPerfSpringRunner.java    From quickperf with Apache License 2.0 5 votes vote down vote up
@Override
protected List<MethodRule> rules(Object target) {
    if (SystemProperties.TEST_CODE_EXECUTING_IN_NEW_JVM.evaluate()) {
        return QUICK_PERF_SPRING_RUNNER_FOR_SPECIFIC_JVM.rules(target);
    }
    if(quickPerfFeaturesAreDisabled) {
        return springRunner.rules(target);
    }
    return super.rules(target);
}
 
Example #3
Source File: RuleContext.java    From spectrum with MIT License 5 votes vote down vote up
/**
 * Find the method rules within the test class mixin.
 * @param target the test case instance
 * @return a list of TestRules that should be applied when executing this
 *         test
 */
private List<MethodRule> getMethodRules(final Object target) {
  return Stream.concat(
      testClass.getAnnotatedMethodValues(target, Rule.class, MethodRule.class).stream(),
      testClass.getAnnotatedFieldValues(target, Rule.class, MethodRule.class).stream())
      .collect(Collectors.toList());
}
 
Example #4
Source File: RuleContext.java    From spectrum with MIT License 5 votes vote down vote up
private Statement decorateWithMethodRules(final Statement base,
    final List<MethodRule> methodRules,
    final FrameworkMethod method) {
  Statement result = base;
  for (MethodRule each : methodRules) {
    result = each.apply(result, method, currentTestObject);
  }

  return result;
}
 
Example #5
Source File: QuickPerfSpringRunner.java    From quickperf with Apache License 2.0 5 votes vote down vote up
@Override
protected List<MethodRule> rules(Object target) {
    if (SystemProperties.TEST_CODE_EXECUTING_IN_NEW_JVM.evaluate()) {
        return QUICK_PERF_SPRING_RUNNER_FOR_SPECIFIC_JVM.rules(target);
    }
    if(quickPerfFeaturesAreDisabled) {
        return springRunner.rules(target);
    }
    return super.rules(target);
}
 
Example #6
Source File: JpaUnitRule.java    From jpa-unit with Apache License 2.0 5 votes vote down vote up
@Override
public Statement apply(final Statement result, final FrameworkMethod method, final Object target) {
    Statement lastResult = result;

    for (final MethodRule rule : getRules()) {
        lastResult = rule.apply(lastResult, method, target);
    }

    return lastResult;
}
 
Example #7
Source File: ExpectedTestFailureRule.java    From tutorials with MIT License 4 votes vote down vote up
public ExpectedTestFailureRule(MethodRule testedRule) {
    this.testedRule = testedRule;
}
 
Example #8
Source File: SpringRunnerWithQuickPerfFeatures.java    From quickperf with Apache License 2.0 4 votes vote down vote up
@Override
protected List<MethodRule> rules(Object target) {
    return super.rules(target);
}
 
Example #9
Source File: OrienteerTestRunner.java    From Orienteer with Apache License 2.0 4 votes vote down vote up
@Override
protected List<MethodRule> rules(Object target) {
	List<MethodRule> result = super.rules(target);
	result.add(0, getInjector().getInstance(SudoRule.class));
	return result;
}
 
Example #10
Source File: RuleContext.java    From spectrum with MIT License 4 votes vote down vote up
private Statement withMethodRules(final Statement base, final List<MethodRule> methodRules) {
  FrameworkMethod method = stubFrameworkMethod();

  return decorateWithMethodRules(base, methodRules, method);
}
 
Example #11
Source File: MethodRuleRegistrar.java    From jpa-unit with Apache License 2.0 4 votes vote down vote up
public static List<MethodRule> registerRules(final List<MethodRule> rules, final DecoratorExecutor executor,
        final ExecutionContext ctx) {
    rules.add((base, method, target) -> new TestMethodStatement(ctx, executor, base, method, target));
    rules.add((base, method, target) -> new TestClassStatement(ctx, executor, base, target));
    return rules;
}
 
Example #12
Source File: JpaUnitRule.java    From jpa-unit with Apache License 2.0 4 votes vote down vote up
private List<MethodRule> getRules() {
    return registerRules(new ArrayList<>(), executor, ctx);
}
 
Example #13
Source File: JpaUnitRunner.java    From jpa-unit with Apache License 2.0 4 votes vote down vote up
@Override
protected List<MethodRule> rules(final Object target) {
    return registerRules(super.rules(target), executor, JpaUnitContext.getInstance(getTestClass().getJavaClass()));
}
 
Example #14
Source File: SpringRunnerWithCallableProtectedMethods.java    From quickperf with Apache License 2.0 4 votes vote down vote up
@Override
protected List<MethodRule> rules(Object target) {
    return super.rules(target);
}
 
Example #15
Source File: SpringRunnerWithQuickPerfFeatures.java    From quickperf with Apache License 2.0 4 votes vote down vote up
@Override
protected List<MethodRule> rules(Object target) {
    return super.rules(target);
}
 
Example #16
Source File: SpringRunnerWithCallableProtectedMethods.java    From quickperf with Apache License 2.0 4 votes vote down vote up
@Override
protected List<MethodRule> rules(Object target) {
    return super.rules(target);
}
 
Example #17
Source File: SpringRunnerWithQuickPerfFeatures.java    From quickperf with Apache License 2.0 4 votes vote down vote up
@Override
protected List<MethodRule> rules(Object target) {
    return super.rules(target);
}
 
Example #18
Source File: SpringRunnerWithCallableProtectedMethods.java    From quickperf with Apache License 2.0 4 votes vote down vote up
@Override
protected List<MethodRule> rules(Object target) {
    return super.rules(target);
}