/** * Returns a {@link 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 = testClass .getAnnotatedMethods(BeforeClass.class); return befores.isEmpty() ? statement : new RunBefores(statement, befores, null); }
new RunBefores(new Statement() { public void evaluate() { }, list, target).evaluate();
@Override public void evaluate() throws Throwable { for (FrameworkMethod before : befores) { invokeMethod(before); } next.evaluate(); }
@Override public void evaluate() throws Throwable { // As the fNext field is set from ContiPerfRule using reflection, we need to set the underlying next field in // order the Statement to work Field next = this.getClass().getSuperclass().getDeclaredField("next"); next.setAccessible(true); next.set(this, fNext); super.evaluate(); }
/** * Returns a {@link 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 = fTestClass .getAnnotatedMethods(BeforeClass.class); return befores.isEmpty() ? statement : new RunBefores(statement, befores, null); }
private void initializeIfNecessary(Object target) { TestClass testClass = new TestClass(target.getClass()); List<FrameworkMethod> befores = testClass.getAnnotatedMethods(Before.class); if (!befores.isEmpty()) { logger.debug("Running @Before methods"); try { new RunBefores(new Statement() { @Override public void evaluate() { } }, befores, target).evaluate(); } catch (Throwable e) { Assert.assertThat(e, CoreMatchers.not(CoreMatchers.anything())); } initialized = true; } if (!testClass.getAnnotatedMethods(After.class).isEmpty()) { initialized = true; } }
/** * Returns a {@link 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. */ 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); }
new RunBefores(new Statement() { public void evaluate() { }, list, target).evaluate();
/** * Returns a {@link 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); }
private Statement withBefores(Statement statement) { List<FrameworkMethod> befores = getTestClass().getAnnotatedMethods(Before.class); return befores.isEmpty() ? statement : new RunBefores(statement, befores, instance); }
/** * Returns a {@link 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 = fTestClass .getAnnotatedMethods(BeforeClass.class); return befores.isEmpty() ? statement : new RunBefores(statement, befores, null); }
/** * Returns a {@link 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); }
/** * Returns a {@link 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. * * @param statement statement * @return wrapped statement */ protected Statement withBeforeProcess(Statement statement) { TestClass testClass = getTestClass(); List<FrameworkMethod> befores = testClass.getAnnotatedMethods(BeforeProcess.class); befores.addAll(testClass.getAnnotatedMethods(BeforeClass.class)); return befores.isEmpty() ? statement : new RunBefores(statement, befores, null); }
@Override protected Statement withBefores(FrameworkMethod method, Object target, Statement statement) { return new RunBefores(statement, new ArrayList<FrameworkMethod>(), target); }
/** * Returns a {@link 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 = testClass .getAnnotatedMethods(BeforeClass.class); return befores.isEmpty() ? statement : new RunBefores(statement, befores, null); }
public static RunBefores createRunBeforesForTestInput(Statement statement, List<TupleConsumer> tupleConsumers, Tuple testInput) { return new RunBefores( statement, tupleConsumers.stream().map( frameworkMethodInvokingArgumentsFromTestCase(testInput) ).collect(toList()), null ); }
@SuppressWarnings("unchecked") @Override protected Statement withBefores(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> befores = testClassFromClassLoader .getAnnotatedMethods((Class<? extends Annotation>) beforeFromClassLoader); return new RunBefores(statement, befores, target); }
/** * Returns a {@link 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 = fTestClass .getAnnotatedMethods(BeforeClass.class); return befores.isEmpty() ? statement : new RunBefores(statement, befores, null); }
@SuppressWarnings("unchecked") @Override protected Statement withBefores(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> befores = testClassFromClassLoader .getAnnotatedMethods((Class<? extends Annotation>) beforeFromClassLoader); return new RunBefores(statement, befores, target); }
public static RunBefores createRunBeforesForTestInput(Statement statement, List<TupleConsumer> tupleConsumers, Tuple testInput) { return new RunBefores( statement, tupleConsumers.stream().map( frameworkMethodInvokingArgumentsFromTestCase(testInput) ).collect(toList()), null ); }