Package org.junit.rules

Examples of org.junit.rules.TestRule


        @Override
        protected List<TestRule> getTestRules(final Object test) {
            final LinkedList<TestRule> methodRules = new LinkedList<TestRule>(
                    super.getTestRules(test));
            methodRules.add(new TestRule() {
                public Statement apply(Statement base, Description description) {
                    return new FlipBitRule().apply(base, null, test);
                }
            });
            return methodRules;
View Full Code Here


            final Statement statement;
            if (fieldValue instanceof MethodRule) {
                // the MethodRule is known by junit 4.9 -> delegate to super-class
                statement = super.applyRuleToLastStatement(method, testInstance, field, lastStatement);
            } else if (fieldValue instanceof TestRule){
                TestRule rule = (TestRule) fieldValue;
                statement = rule.apply(lastStatement, description);
            } else {
                throw new IllegalStateException("Can only handle MethodRule and TestRule");
            }
            return statement;
        }
View Full Code Here

    @Override
    protected List<TestRule> getTestRules(final Object test) {
      final LinkedList<TestRule> methodRules= new LinkedList<TestRule>(
          super.getTestRules(test));
      methodRules.add(new TestRule() {       
        public Statement apply(Statement base, Description description) {
          return new FlipBitRule().apply(base, null, test);
        }
      });
      return methodRules;
View Full Code Here

  public void intercept(final IMethodInvocation invocation) throws Throwable {
    Statement stat = createBaseStatement(invocation);

    for (FieldInfo field : ruleFields) {
      TestRule rule = (TestRule) getRuleInstance(field, invocation.getInstance());
      stat = rule.apply(stat, invocation.getIteration().getDescription());
    }

    stat.evaluate();
  }
View Full Code Here

  public void intercept(final IMethodInvocation invocation) throws Throwable {
    Statement stat = createBaseStatement(invocation);

    for (FieldInfo field : ruleFields) {
      TestRule rule = (TestRule) getRuleInstance(field, field.isShared() ? invocation.getSharedInstance() : invocation.getInstance());
      stat = rule.apply(stat, invocation.getSpec().getDescription());
    }

    stat.evaluate();
  }
View Full Code Here

TOP

Related Classes of org.junit.rules.TestRule

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.