Package org.junit.runners.model

Examples of org.junit.runners.model.Statement


       {
           Method withRules = BlockJUnit4ClassRunner.class.getDeclaredMethod("withRules",
                   new Class[] {FrameworkMethod.class, Object.class, Statement.class});
           withRules.setAccessible(true);

           Statement statement = methodInvoker(method, test);
           statement = possiblyExpectingExceptions(method, test, statement);
           statement = withPotentialTimeout(method, test, statement);

           final Object testObj = test;
           final Statement testStatement = statement;

           Statement arounds = withBefores(method, test, testStatement);
           arounds = withAfters(method, test, arounds);
           arounds = (Statement)withRules.invoke(this, new Object[] {method, test, arounds});
           final Statement withArounds = arounds;
           return new Statement() {

               @Override
               public void evaluate() throws Throwable {
                   List<Throwable> exceptions = new ArrayList<Throwable>();
                   try {
                       final AtomicInteger integer = new AtomicInteger();
                       adaptor.before(testObj, method.getMethod(), new LifecycleMethodExecutor() {
                           @Override
                           public void invoke() throws Throwable {
                               integer.incrementAndGet();
                           }
                       });
                       try {
                           State.caughtExceptionAfterJunit(null);
                           if(integer.get() > 0) {
                               withArounds.evaluate();
                           } else {
                               testStatement.evaluate();
                           }
                       }
                       catch (Throwable e) {
View Full Code Here


    }

   @Override
   protected Statement methodInvoker(final FrameworkMethod method, final Object test)
   {
      return new Statement()
      {
         @Override
         public void evaluate() throws Throwable
         {
            TestResult result = adaptor.test(new TestMethodExecutor()
View Full Code Here

    }

    @Override
    public Statement apply(final Statement statement,
        final Description description) {
        return new Statement() {
            @Override
            // @checkstyle IllegalThrowsCheck (1 line)
            public void evaluate() throws Throwable {
                statement.evaluate();
            }
View Full Code Here

public final class RepoRule implements TestRule {

    @Override
    public Statement apply(final Statement statement,
        final Description description) {
        return new Statement() {
            @Override
            // @checkstyle IllegalThrowsCheck (1 line)
            public void evaluate() throws Throwable {
                statement.evaluate();
            }
View Full Code Here

    }

    @Override
    public Statement apply(final Statement base, final Description description) {

        return new Statement() {

            @Override
            public void evaluate() throws Throwable {

                try {
View Full Code Here

    }

    @Override
    protected Statement methodInvoker(FrameworkMethod method, Object test) {

        final Statement delegate = super.methodInvoker(method, test);

        return new Statement() {

            @Override
            public void evaluate() throws Throwable {
                try {

                    // create blank instance and set initial state
                    TestFeatureManager featureManager = new TestFeatureManager(featureClass);
                    for (Feature feature : activeFeatures) {
                        featureManager.enable(feature);
                    }

                    // register the test instance
                    TestFeatureManagerProvider.setFeatureManager(featureManager);
                    FeatureContext.clearCache();

                    // run the test
                    delegate.evaluate();

                }

                finally {
                    TestFeatureManagerProvider.setFeatureManager(null);
View Full Code Here

*
* @since 4.9
*/
public abstract class TestWatcher implements TestRule {
    public Statement apply(final Statement base, final Description description) {
        return new Statement() {
            @Override
            public void evaluate() throws Throwable {
                List<Throwable> errors = new ArrayList<Throwable>();

                startingQuietly(description, errors);
View Full Code Here

    public Statement apply(Statement base, Description description) {
        return statement(base);
    }

    private Statement statement(final Statement base) {
        return new Statement() {
            @Override
            public void evaluate() throws Throwable {
                before();
                try {
                    base.evaluate();
View Full Code Here

     * </ol>
     *
     * @return {@code Statement}
     */
    protected Statement classBlock(final RunNotifier notifier) {
        Statement statement = childrenInvoker(notifier);
        if (!areAllChildrenIgnored()) {
            statement = withBeforeClasses(statement);
            statement = withAfterClasses(statement);
            statement = withClassRules(statement);
        }
View Full Code Here

     * Returns a {@link Statement}: Call {@link #runChild(Object, RunNotifier)}
     * on each object returned by {@link #getChildren()} (subject to any imposed
     * filter and sort)
     */
    protected Statement childrenInvoker(final RunNotifier notifier) {
        return new Statement() {
            @Override
            public void evaluate() {
                runChildren(notifier);
            }
        };
View Full Code Here

TOP

Related Classes of org.junit.runners.model.Statement

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.