Search in sources :

Example 1 with TimesStatement

use of org.eclipse.scout.rt.testing.platform.runner.statement.TimesStatement in project scout.rt by eclipse.

the class PlatformTestRunner method interceptMethodLevelStatement.

/**
 * Overwrite this method to contribute some 'method-level' behavior to this Runner.
 * <p>
 * Contributions are plugged according to the design pattern: 'chain-of-responsibility' - it is easiest to read the
 * chain from 'bottom-to-top'.
 * <p>
 * To contribute on top of the chain (meaning that you are invoked <strong>after</strong> the contributions of super
 * classes and therefore can base on their contributed functionality), you can use constructions of the following
 * form:
 * <p>
 * <code>
 *   Statement s2 = new YourInterceptor2(<strong>next</strong>); // executed 3th<br/>
 *   Statement s1 = new YourInterceptor1(s2); // executed 2nd<br/>
 *   Statement head = <i>super.interceptMethodLevelStatement(s1)</i>; // executed 1st<br/>
 *   return head;
 * </code>
 * </p>
 * To be invoked <strong>before</strong> the super class contributions, you can use constructions of the following
 * form:
 * <p>
 * <code>
 *   Statement s2 = <i>super.interceptMethodLevelStatement(<strong>next</strong>)</i>; // executed 3th<br/>
 *   Statement s1 = new YourInterceptor2(s2); // executed 2nd<br/>
 *   Statement head = new YourInterceptor1(s1); // executed 1st<br/>
 *   return head;
 * </code>
 *
 * @param next
 *          subsequent {@link Statement}.
 * @return the head of the chain to be invoked first.
 */
protected Statement interceptMethodLevelStatement(final Statement next, final Class<?> testClass, final Method testMethod) {
    final Statement s5 = new ClearThreadInterruptionStatusStatement(next);
    final Statement s4 = new SubjectStatement(s5, ReflectionUtility.getAnnotation(RunWithSubject.class, testMethod, testClass));
    // exception handler to not silently swallow handled exceptions.
    final Statement s3 = new RegisterBeanStatement(s4, new BeanMetaData(JUnitExceptionHandler.class).withReplace(true).withOrder(-1000));
    final Statement s2 = new AssertNoRunningJobsStatement(s3, "Test method");
    final Statement s1 = new TimesStatement(s2, ReflectionUtility.getAnnotation(Times.class, testMethod, testClass));
    return s1;
}
Also used : SubjectStatement(org.eclipse.scout.rt.testing.platform.runner.statement.SubjectStatement) TimesStatement(org.eclipse.scout.rt.testing.platform.runner.statement.TimesStatement) BeanMetaData(org.eclipse.scout.rt.platform.BeanMetaData) Statement(org.junit.runners.model.Statement) SubjectStatement(org.eclipse.scout.rt.testing.platform.runner.statement.SubjectStatement) BeanAnnotationsCleanupStatement(org.eclipse.scout.rt.testing.platform.runner.statement.BeanAnnotationsCleanupStatement) AssertNoRunningJobsStatement(org.eclipse.scout.rt.testing.platform.runner.statement.AssertNoRunningJobsStatement) TimeoutRunContextStatement(org.eclipse.scout.rt.testing.platform.runner.statement.TimeoutRunContextStatement) BeanAnnotationsInitStatement(org.eclipse.scout.rt.testing.platform.runner.statement.BeanAnnotationsInitStatement) RegisterBeanStatement(org.eclipse.scout.rt.testing.platform.runner.statement.RegisterBeanStatement) ThrowHandledExceptionStatement(org.eclipse.scout.rt.testing.platform.runner.statement.ThrowHandledExceptionStatement) ClearThreadInterruptionStatusStatement(org.eclipse.scout.rt.testing.platform.runner.statement.ClearThreadInterruptionStatusStatement) RunContextStatement(org.eclipse.scout.rt.testing.platform.runner.statement.RunContextStatement) PlatformStatement(org.eclipse.scout.rt.testing.platform.runner.statement.PlatformStatement) TransactionAddFailureOnAnyExceptionStatement(org.eclipse.scout.rt.testing.platform.runner.statement.TransactionAddFailureOnAnyExceptionStatement) TimesStatement(org.eclipse.scout.rt.testing.platform.runner.statement.TimesStatement) RegisterBeanStatement(org.eclipse.scout.rt.testing.platform.runner.statement.RegisterBeanStatement) ClearThreadInterruptionStatusStatement(org.eclipse.scout.rt.testing.platform.runner.statement.ClearThreadInterruptionStatusStatement) AssertNoRunningJobsStatement(org.eclipse.scout.rt.testing.platform.runner.statement.AssertNoRunningJobsStatement)

Aggregations

BeanMetaData (org.eclipse.scout.rt.platform.BeanMetaData)1 AssertNoRunningJobsStatement (org.eclipse.scout.rt.testing.platform.runner.statement.AssertNoRunningJobsStatement)1 BeanAnnotationsCleanupStatement (org.eclipse.scout.rt.testing.platform.runner.statement.BeanAnnotationsCleanupStatement)1 BeanAnnotationsInitStatement (org.eclipse.scout.rt.testing.platform.runner.statement.BeanAnnotationsInitStatement)1 ClearThreadInterruptionStatusStatement (org.eclipse.scout.rt.testing.platform.runner.statement.ClearThreadInterruptionStatusStatement)1 PlatformStatement (org.eclipse.scout.rt.testing.platform.runner.statement.PlatformStatement)1 RegisterBeanStatement (org.eclipse.scout.rt.testing.platform.runner.statement.RegisterBeanStatement)1 RunContextStatement (org.eclipse.scout.rt.testing.platform.runner.statement.RunContextStatement)1 SubjectStatement (org.eclipse.scout.rt.testing.platform.runner.statement.SubjectStatement)1 ThrowHandledExceptionStatement (org.eclipse.scout.rt.testing.platform.runner.statement.ThrowHandledExceptionStatement)1 TimeoutRunContextStatement (org.eclipse.scout.rt.testing.platform.runner.statement.TimeoutRunContextStatement)1 TimesStatement (org.eclipse.scout.rt.testing.platform.runner.statement.TimesStatement)1 TransactionAddFailureOnAnyExceptionStatement (org.eclipse.scout.rt.testing.platform.runner.statement.TransactionAddFailureOnAnyExceptionStatement)1 Statement (org.junit.runners.model.Statement)1