@Override protected Statement withAfterClasses( Statement statement ) { try { Statement newStatement = super.withAfterClasses(statement); final Method tearDownMethod = GeoWaveITSuiteRunner.class.getDeclaredMethod("tearDown"); tearDownMethod.setAccessible(true); return new RunAfters( newStatement, Collections.singletonList(new FrameworkMethod( tearDownMethod)), this); } catch (NoSuchMethodException | SecurityException e) { LOGGER.warn( "Unable to find tearDown method", e); } return super.withAfterClasses(statement); }
@Override protected Statement withAfterClasses( final Statement statement ) { // add test environment tear down try { final Statement newStatement = super.withAfterClasses(statement); final Method tearDownMethod = GeoWaveITRunner.class.getDeclaredMethod("tearDown"); tearDownMethod.setAccessible(true); return new RunAfters( newStatement, Collections.singletonList(new FrameworkMethod( tearDownMethod)), this); } catch (NoSuchMethodException | SecurityException e) { LOGGER.warn( "Unable to find tearDown method", e); } return super.withAfterClasses(statement); }
/** * Adds any @AfterAll methods to be run after the normal @After annotated methods for the last test method only. * <p> * {@inheritDoc} */ @Override protected Statement withAfters(final FrameworkMethod method, final Object target, final Statement stmt) { ensureInitialized(); Statement statement = super.withAfters(method, target, stmt); // NOPMD.CloseResource if (method.equals(Iterables.getLast(expectedMethods))) { final List<FrameworkMethod> afters = getTestClass().getAnnotatedMethods(AfterAll.class); statement = afters.isEmpty() ? statement : new RunAfters(statement, afters, target); } return statement; }
@Override protected synchronized Statement withAfters(FrameworkMethod method, Object target, Statement statement) { // We now to need to search in the class from the custom loader. //We also need to search with the annotation loaded by the custom class loader or otherwise we don't find any method. List<FrameworkMethod> afters = testClassFromClassLoader .getAnnotatedMethods((Class<? extends Annotation>) afterFromClassLoader); return new RunAfters(statement, afters, target); }
/** * Returns a {@link Statement}: run all non-overridden {@code @After} * methods on this class and superclasses before running {@code next}; all * After methods are always executed: exceptions thrown by previous steps * are combined, if necessary, with exceptions from After methods into a * {@link MultipleFailureException}. */ protected Statement withAfters(FrameworkMethod method, Object target, Statement statement) { List<FrameworkMethod> afters = getTestClass().getAnnotatedMethods( After.class); return afters.isEmpty() ? statement : new RunAfters(statement, afters, target); }
/** * Returns a {@link Statement}: run all non-overridden {@code @After} * methods on this class and superclasses before running {@code next}; all * After methods are always executed: exceptions thrown by previous steps * are combined, if necessary, with exceptions from After methods into a * {@link MultipleFailureException}. * * @deprecated Will be private soon: use Rules instead */ @Override protected Statement withAfters(FrameworkMethod method, Object target, Statement statement) { List<FrameworkMethod> afters= getTestClass().getAnnotatedMethods( After.class); afters = convert(afters); return afters.isEmpty() ? statement : new RunAfters(statement, afters, target); }
@Override protected Statement withAfterClasses(Statement statement) { List<FrameworkMethod> afters = getTestClass().getAnnotatedMethods(AfterClass.class); afters = convert(afters); return afters.isEmpty() ? statement : new RunAfters(statement, afters, null); }
@Test public void givenTestClassWithAfterClassAnnotatedMethods_returnsRunAfterStatement() throws Exception { List<FrameworkMethod> afters = Arrays.asList(method1, method2); when(testClass.getAnnotatedMethods(AfterClass.class)).thenReturn(afters); Statement actual = builder.createStatement(testClass, next, description, notifier); assertThat(actual, is(instanceOf(RunAfters.class))); }
@Override @SneakyThrows(NoSuchMethodException.class) protected Statement withAfterClasses(Statement statement) { final FrameworkMethod fm = new FrameworkMethod(XTFTestSuite.class.getDeclaredMethod("afterSuite")); return new RunAfters(statement, join(fm, getTestClass().getAnnotatedMethods(AfterClass.class), false), null); }
@Override protected Statement withAfterClasses(Statement statement) { Class<? extends Annotation> afterClass = loadClassFromClassLoader(AfterClass.class, cl); List<FrameworkMethod> afters = testClass.getAnnotatedMethods(afterClass); return afters.isEmpty() ? statement : new RunAfters(statement, afters, null); }
@Override protected Statement withAfters(FrameworkMethod method, Object target, Statement statement) { Class<? extends Annotation> after = loadClassFromClassLoader(After.class, cl); List<FrameworkMethod> afters = getTestClass().getAnnotatedMethods(after); return afters.isEmpty() ? statement : new RunAfters(statement, afters, target); }
public static RunAftersContiPerfAdapter create(RunAfters runBefores, Statement next) throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException { List<FrameworkMethod> befores = ReflectionUtils.getObjectByField(runBefores, runBefores.getClass(), "afters"); Object target = ReflectionUtils.getObjectByField(runBefores, runBefores.getClass(), "target"); return new RunAftersContiPerfAdapter(next, befores, target); }
protected Statement prepareAfterClasses(TestClass extension, Statement base) { return new RunAfters( base, extension.getAnnotatedMethods(AfterClass.class), null); }
protected Statement prepareAfters(TestClass extension, Statement base, Object target) { return new RunAfters( base, extension.getAnnotatedMethods(After.class), target); }
@Override protected Statement withAfterClasses(Statement statement) { List<FrameworkMethod> afters= getTestClass().getAnnotatedMethods(AfterPinpointPluginTest.class); return afters.isEmpty() ? statement : new RunAfters(statement, afters, null); }
public Statement createStatement(final TestClass testClass, final Statement next, final Description description, final RunNotifier notifier) { final List<FrameworkMethod> afters = testClass.getAnnotatedMethods(AfterClass.class); return afters.isEmpty() ? next : new RunAfters(next, afters, null); }
protected Statement withSetupTeardownAfters(Object target, Statement statement) { List<FrameworkMethod> befores = getMethods(target.getClass(), After.class); return befores.isEmpty() ? statement : new RunAfters(statement, befores, target); }
protected Statement withAfterSetupTeardownClasses(Object setupTeardown, Statement statement) { List<FrameworkMethod> teardowns = getMethods(setupTeardown.getClass(), AfterClass.class); return teardowns.isEmpty() ? statement : new RunAfters(statement, teardowns, null); }
/** * Returns a {@link Statement}: run all non-overridden {@code @AfterClass} methods on this class * and superclasses after executing {@code statement}; all AfterClass methods are * always executed: exceptions thrown by previous steps are combined, if * necessary, with exceptions from AfterClass methods into a * {@link org.junit.runners.model.MultipleFailureException}. * * @see ParentRunner#withAfterClasses(org.junit.runners.model.Statement) */ public static Statement withAfterClasses(Statement statement, TestClass testClass) { List<FrameworkMethod> afters = testClass .getAnnotatedMethods(AfterClass.class); return afters.isEmpty() ? statement : new RunAfters(statement, afters, null); }
/** * Returns a {@link org.junit.runners.model.Statement}: run all non-overridden {@code @AfterClass} methods on this class * and superclasses before executing {@code statement}; all AfterClass methods are * always executed: exceptions thrown by previous steps are combined, if * necessary, with exceptions from AfterClass methods into a * {@link org.junit.runners.model.MultipleFailureException}. */ protected Statement withAfterClasses(Statement statement) { List<FrameworkMethod> afters = getTestClass() .getAnnotatedMethods(AfterClass.class); return afters.isEmpty() ? statement : new RunAfters(statement, afters, null); }
/** * Returns a {@link org.junit.runners.model.Statement}: run all non-overridden {@code @After} * methods on this class and superclasses before running {@code next}; all * After methods are always executed: exceptions thrown by previous steps * are combined, if necessary, with exceptions from After methods into a * {@link org.junit.runners.model.MultipleFailureException}. * * @deprecated Will be private soon: use Rules instead */ @Deprecated protected Statement withAfters(FrameworkMethod method, Object target, Statement statement) { List<FrameworkMethod> afters = getTestClass().getAnnotatedMethods( After.class); return afters.isEmpty() ? statement : new RunAfters(statement, afters, target); }
/** * Returns a {@link Statement}: run all non-overridden {@code @AfterClass} methods on this class * and superclasses before executing {@code statement}; all AfterClass methods are * always executed: exceptions thrown by previous steps are combined, if * necessary, with exceptions from AfterClass methods into a * {@link MultipleFailureException}. */ protected Statement withAfterClasses(Statement statement) { List<FrameworkMethod> afters= fTestClass .getAnnotatedMethods(AfterClass.class); return afters.isEmpty() ? statement : new RunAfters(statement, afters, null); }
/** * Returns a {@link Statement}: run all non-overridden {@code @AfterClass} methods on this class * and superclasses before executing {@code statement}; all AfterClass methods are * always executed: exceptions thrown by previous steps are combined, if * necessary, with exceptions from AfterClass methods into a * {@link org.junit.runners.model.MultipleFailureException}. */ protected Statement withAfterClasses(Statement statement) { List<FrameworkMethod> afters = fTestClass .getAnnotatedMethods(AfterClass.class); return afters.isEmpty() ? statement : new RunAfters(statement, afters, null); }
/** * Returns a {@link Statement}: run all non-overridden {@code @After} * methods on this class and superclasses before running {@code next}; all * After methods are always executed: exceptions thrown by previous steps * are combined, if necessary, with exceptions from After methods into a * {@link MultipleFailureException}. * * @deprecated Will be private soon: use Rules instead */ @Deprecated protected Statement withAfters(FrameworkMethod method, Object target, Statement statement) { List<FrameworkMethod> afters = getTestClass().getAnnotatedMethods( After.class); return afters.isEmpty() ? statement : new RunAfters(statement, afters, target); }
/** * Returns a {@link Statement}: run all non-overridden {@code @AfterClass} methods on this class * and superclasses before executing {@code statement}; all AfterClass methods are * always executed: exceptions thrown by previous steps are combined, if * necessary, with exceptions from AfterClass methods into a * {@link MultipleFailureException}. */ protected Statement withAfterClasses(Statement statement) { List<FrameworkMethod> afters = fTestClass .getAnnotatedMethods(AfterClass.class); return afters.isEmpty() ? statement : new RunAfters(statement, afters, null); }