org.junit.rules.RunRules Java Examples

The following examples show how to use org.junit.rules.RunRules. 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: EndToEndRunner.java    From buck with Apache License 2.0 5 votes vote down vote up
private Statement withRules(EndToEndTestDescriptor child, Object target, Statement statement) {
  // We do not support MethodRules like the JUnit runner does as it has been functionally
  // replaced by TestRules (https://junit.org/junit4/javadoc/4.12/org/junit/rules/MethodRule.html)
  List<TestRule> testRules =
      getTestClass().getAnnotatedMethodValues(target, Rule.class, TestRule.class);
  testRules.addAll(getTestClass().getAnnotatedFieldValues(target, Rule.class, TestRule.class));
  return testRules.isEmpty()
      ? statement
      : new RunRules(statement, testRules, describeChild(child));
}
 
Example #2
Source File: ParameterTest.java    From openCypher with Apache License 2.0 4 votes vote down vote up
/**
 * @see org.junit.runners.BlockJUnit4ClassRunner#withTestRules(FrameworkMethod, List, Statement)
 */
private Statement withTestRules( FrameworkMethod method, List<TestRule> testRules, Statement statement )
{
    return testRules.isEmpty() ? statement : new RunRules( statement, testRules, describeChild( method ) );
}
 
Example #3
Source File: RuleContext.java    From spectrum with MIT License 4 votes vote down vote up
private Statement withTestRules(final List<TestRule> testRules, final Statement statement,
    final Description childDescription) {
  return testRules.isEmpty() ? statement : new RunRules(statement, testRules, childDescription);
}
 
Example #4
Source File: RuleContext.java    From spectrum with MIT License 4 votes vote down vote up
private synchronized Statement withClassRules(final Statement base,
    final Description description) {
  List<TestRule> classRules = getClassRules();

  return classRules.isEmpty() ? base : new RunRules(base, classRules, description);
}
 
Example #5
Source File: PinpointPluginTestSuite.java    From pinpoint with Apache License 2.0 4 votes vote down vote up
private Statement withClassRules(Statement statement) {
    List<TestRule> classRules = classRules();
    return classRules.isEmpty() ? statement :
            new RunRules(statement, classRules, getDescription());
}
 
Example #6
Source File: BrowserVersionClassRunner.java    From htmlunit with Apache License 2.0 2 votes vote down vote up
/**
 * Returns a Statement.
 *
 * @param statement The base statement
 * @return a RunRules statement if any class-level Rule are found, or the base statement
 */
private Statement withTestRules(final FrameworkMethod method, final Object target, final Statement statement) {
    final List<TestRule> testRules = getTestRules(target);
    return testRules.isEmpty() ? statement : new RunRules(statement, testRules, describeChild(method));
}
 
Example #7
Source File: LoadTimeWeavableTestRunner.java    From rice with Educational Community License v2.0 2 votes vote down vote up
/**
 * Returns a {@link org.junit.runners.model.Statement}: apply all
 * static fields assignable to {@link org.junit.rules.TestRule}
 * annotated with {@link org.junit.ClassRule}.
 *
 * @param statement the base statement
 * @return a RunRules statement if any class-level {@link org.junit.Rule}s are
 *         found, or the base statement
 */
private Statement withClassRules(Statement statement) {
    List<TestRule> classRules = classRules();
    return classRules.isEmpty() ? statement :
            new RunRules(statement, classRules, getDescription());
}
 
Example #8
Source File: LoadTimeWeavableTestRunner.java    From rice with Educational Community License v2.0 2 votes vote down vote up
/**
 * Returns a {@link org.junit.runners.model.Statement}: apply all non-static value fields
 * annotated with {@link org.junit.Rule}.
 *
 * @param statement The base statement
 * @return a RunRules statement if any class-level {@link org.junit.Rule}s are
 *         found, or the base statement
 */
private Statement withTestRules(FrameworkMethod method, List<TestRule> testRules,
        Statement statement) {
    return testRules.isEmpty() ? statement :
            new RunRules(statement, testRules, describeChild(method));
}