org.junit.internal.runners.statements.RunBefores Java Examples

The following examples show how to use org.junit.internal.runners.statements.RunBefores. 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: GeoWaveITRunner.java    From geowave with Apache License 2.0 6 votes vote down vote up
@Override
protected Statement withBeforeClasses(final Statement statement) {
  // add test environment setup
  try {
    final Method setupMethod = GeoWaveITRunner.class.getDeclaredMethod("setup");
    setupMethod.setAccessible(true);
    return super.withBeforeClasses(
        new RunBefores(
            statement,
            Collections.singletonList(new FrameworkMethod(setupMethod)),
            this));
  } catch (NoSuchMethodException | SecurityException e) {
    LOGGER.warn("Unable to find setup method", e);
  }

  return super.withBeforeClasses(statement);
}
 
Example #2
Source File: WebTauRunner.java    From webtau with Apache License 2.0 5 votes vote down vote up
@Override
protected Statement withBeforeClasses(Statement statement) {
    List<FrameworkMethod> befores = wrapInWebTauTestEntry(getTestClass()
            .getAnnotatedMethods(BeforeClass.class));
    return befores.isEmpty() ? statement :
            new RunBefores(statement, befores, null);
}
 
Example #3
Source File: ColaTestRunner.java    From COLA with GNU Lesser General Public License v2.1 5 votes vote down vote up
protected Statement withColaBefores(FrameworkMethod method, Object target,
                                    Statement statement) {
    List<FrameworkMethod> befores = getTestClass().getAnnotatedMethods(
        ColaBefore.class);
    return befores.isEmpty() ? statement : new RunBefores(statement,
        befores, target);
}
 
Example #4
Source File: ColaTestUnitRunner.java    From COLA with GNU Lesser General Public License v2.1 5 votes vote down vote up
protected Statement withColaBefores(FrameworkMethod method, Object target,
                                    Statement statement) {
    List<FrameworkMethod> befores = getTestClass().getAnnotatedMethods(
        ColaBefore.class);
    return befores.isEmpty() ? statement : new RunBefores(statement,
        befores, target);
}
 
Example #5
Source File: SystemTestRunner.java    From pravega with Apache License 2.0 5 votes vote down vote up
private Statement withEnvironment(Statement statement) {
    List<FrameworkMethod> environment = super.getTestClass().getAnnotatedMethods(Environment.class);
    if (environment.isEmpty()) {
        log.error("@Environment annotation not used for system test , {}", getTestClass().getName());
        return statement;
    } else {
        return new RunBefores(statement, environment, null);
    }
}
 
Example #6
Source File: ClassRunner.java    From dsl-devkit with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Adds any @BeforeAll methods to be run before the normal @Before annotated methods for the first test method only.
 * <p>
 * {@inheritDoc}
 */
@Override
protected Statement withBefores(final FrameworkMethod method, final Object target, final Statement stmt) {
  ensureInitialized();
  Statement statement = super.withBefores(method, target, stmt); // NOPMD.CloseResource
  if (method.equals(expectedMethods.get(0))) {
    // reverse BeforeAll method order to get a 'runs top to bottom' order
    final List<FrameworkMethod> befores = Lists.reverse(getTestClass().getAnnotatedMethods(BeforeAll.class));
    statement = befores.isEmpty() ? statement : new RunBefores(statement, befores, target);
  }
  return statement;
}
 
Example #7
Source File: LoadTimeWeavableTestRunner.java    From rice with Educational Community License v2.0 5 votes vote down vote up
/**
 * Returns a {@link org.junit.runners.model.Statement}: run all non-overridden {@code @BeforeClass} methods on this class
 * and superclasses before executing {@code statement}; if any throws an
 * Exception, stop execution and pass the exception on.
 */
protected Statement withBeforeClasses(Statement statement) {
    List<FrameworkMethod> befores = getTestClass()
            .getAnnotatedMethods(BeforeClass.class);
    return befores.isEmpty() ? statement :
            new RunBefores(statement, befores, null);
}
 
Example #8
Source File: LoadTimeWeavableTestRunner.java    From rice with Educational Community License v2.0 5 votes vote down vote up
/**
 * Returns a {@link org.junit.runners.model.Statement}: run all non-overridden {@code @Before}
 * methods on this class and superclasses before running {@code next}; if
 * any throws an Exception, stop execution and pass the exception on.
 *
 * @deprecated Will be private soon: use Rules instead
 */
@Deprecated
protected Statement withBefores(FrameworkMethod method, Object target,
        Statement statement) {
    List<FrameworkMethod> befores = getTestClass().getAnnotatedMethods(Before.class);
    return befores.isEmpty() ? statement : new RunBefores(statement,
            befores, target);
}
 
Example #9
Source File: ParameterTest.java    From openCypher with Apache License 2.0 4 votes vote down vote up
/**
 * @see org.junit.runners.BlockJUnit4ClassRunner#withBefores(FrameworkMethod, Object, Statement)
 */
private Statement withBefores( Object target, Statement statement )
{
    List<FrameworkMethod> befores = getTestClass().getAnnotatedMethods( Before.class );
    return befores.isEmpty() ? statement : new RunBefores( statement, befores, target );
}
 
Example #10
Source File: RunBeforesContiPerfAdapter.java    From components with Apache License 2.0 4 votes vote down vote up
public static RunBeforesContiPerfAdapter create(RunBefores runBefores, Statement next)
        throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException {
    List<FrameworkMethod> befores = ReflectionUtils.getObjectByField(runBefores, runBefores.getClass(), "befores");
    Object target = ReflectionUtils.getObjectByField(runBefores, runBefores.getClass(), "target");
    return new RunBeforesContiPerfAdapter(next, befores, target);
}
 
Example #11
Source File: RuleContext.java    From spectrum with MIT License 4 votes vote down vote up
private Statement withBeforeClasses(final Statement base) {
  List<FrameworkMethod> befores = getBeforeClassMethods();

  return befores.isEmpty() ? base : new RunBefores(base, befores, null);
}
 
Example #12
Source File: AbstractPinpointPluginTestSuite.java    From pinpoint with Apache License 2.0 4 votes vote down vote up
@Override
protected Statement withBeforeClasses(Statement statement) {
    List<FrameworkMethod> befores= getTestClass().getAnnotatedMethods(BeforePinpointPluginTest.class);
    return befores.isEmpty() ? statement : new RunBefores(statement, befores, null);
}
 
Example #13
Source File: EndToEndRunner.java    From buck with Apache License 2.0 4 votes vote down vote up
private Statement withBefores(Object target, Statement statement) {
  List<FrameworkMethod> befores = getTestClass().getAnnotatedMethods(Before.class);
  return befores.isEmpty() ? statement : new RunBefores(statement, befores, target);
}