private Throwable evaluateSafely(Statement base) { try { base.evaluate(); return null; } catch (Throwable throwable) { return throwable; } } };
@Override public void evaluate() throws Throwable { for (FrameworkMethod before : fBefores) { before.invokeExplosively(fTarget); } fNext.evaluate(); } }
/** * @since 4.13 */ protected void invokeMethod(FrameworkMethod method) throws Throwable { method.invokeExplosively(target); } }
/** * Return {@code true} if {@link Ignore @Ignore} is present for the supplied * {@linkplain FrameworkMethod test method} or if the test method is disabled * via {@code @IfProfileValue}. * @see ProfileValueUtils#isTestEnabledInThisEnvironment(Method, Class) */ protected boolean isTestMethodIgnored(FrameworkMethod frameworkMethod) { Method method = frameworkMethod.getMethod(); return (method.isAnnotationPresent(Ignore.class) || !ProfileValueUtils.isTestEnabledInThisEnvironment(method, getTestClass().getJavaClass())); }
/** * Returns the name that describes {@code method} for {@link Description}s. * Default implementation is the method's name */ protected String testName(FrameworkMethod method) { return method.getName(); }
/** * Wrap the supplied {@link Statement} with a {@code SpringRepeat} statement. * <p>Supports Spring's {@link org.springframework.test.annotation.Repeat @Repeat} * annotation. * @see TestAnnotationUtils#getRepeatCount(Method) * @see SpringRepeat */ protected Statement withPotentialRepeat(FrameworkMethod frameworkMethod, Object testInstance, Statement next) { return new SpringRepeat(next, frameworkMethod.getMethod()); }
/** * Evaluates whether {@link FrameworkMethod}s are ignored based on the * {@link Ignore} annotation. */ @Override protected boolean isIgnored(FrameworkMethod child) { return child.getAnnotation(Ignore.class) != null; }
@Override Iterable<FrameworkMethod> getAnnotatablesForTestClass( TestClass testClass) { return testClass.getAnnotatedMethods(); }
protected void scanAnnotatedMembers(Map<Class<? extends Annotation>, List<FrameworkMethod>> methodsForAnnotations, Map<Class<? extends Annotation>, List<FrameworkField>> fieldsForAnnotations) { for (Class<?> eachClass : getSuperClasses(clazz)) { for (Method eachMethod : MethodSorter.getDeclaredMethods(eachClass)) { addToAnnotationLists(new FrameworkMethod(eachMethod), methodsForAnnotations); } // ensuring fields are sorted to make sure that entries are inserted // and read from fieldForAnnotations in a deterministic order for (Field eachField : getSortedDeclaredFields(eachClass)) { addToAnnotationLists(new FrameworkField(eachField), fieldsForAnnotations); } } }
/** * Constructs a new instance of the default runner */ public JUnit4(Class<?> klass) throws InitializationError { super(new TestClass(klass)); } }
/** * Returns, efficiently, all the non-overridden fields in this class and its * superclasses that are annotated. * * @since 4.12 */ public List<FrameworkField> getAnnotatedFields() { return collectValues(fieldsForAnnotations); }
@Override public void evaluate() throws Throwable { try { this.next.evaluate(); } finally { testContextManagerCache.remove(this.testClass); } } }
/** * Retrieve the configured Spring-specific {@code timeout} from the * {@link org.springframework.test.annotation.Timed @Timed} annotation * on the supplied {@linkplain FrameworkMethod test method}. * @return the timeout, or {@code 0} if none was specified * @see TestAnnotationUtils#getTimeout(Method) */ protected long getSpringTimeout(FrameworkMethod frameworkMethod) { return TestAnnotationUtils.getTimeout(frameworkMethod.getMethod()); }
/** * Retrieve the configured JUnit {@code timeout} from the {@link Test @Test} * annotation on the supplied {@linkplain FrameworkMethod test method}. * @return the timeout, or {@code 0} if none was specified */ protected long getJUnitTimeout(FrameworkMethod frameworkMethod) { Test test = frameworkMethod.getAnnotation(Test.class); return (test != null && test.timeout() > 0 ? test.timeout() : 0); }
/** * @since 4.13 */ protected void invokeMethod(FrameworkMethod method) throws Throwable { method.invokeExplosively(target); } }
@Override public void evaluate() throws Throwable { base.evaluate(); ensureResourcesClosed(); } };
/** * Invoke {@link TestContextManager#beforeTestMethod(Object, Method)} * and then evaluate the next {@link Statement} in the execution chain * (typically an instance of * {@link org.junit.internal.runners.statements.RunBefores RunBefores}). */ @Override public void evaluate() throws Throwable { this.testContextManager.beforeTestMethod(this.testInstance, this.testMethod); this.next.evaluate(); }
/** * Invoke {@link TestContextManager#beforeTestExecution(Object, Method)} * and then evaluate the next {@link Statement} in the execution chain * (typically an instance of * {@link org.junit.internal.runners.statements.InvokeMethod InvokeMethod}). */ @Override public void evaluate() throws Throwable { this.testContextManager.beforeTestExecution(this.testInstance, this.testMethod); this.next.evaluate(); }
/** * Invoke {@link TestContextManager#prepareTestInstance(Object)} and * then evaluate the next {@link Statement} in the execution chain * (typically an instance of {@link RunAfterTestMethodCallbacks}). */ @Override public void evaluate() throws Throwable { this.testContextManager.prepareTestInstance(this.testInstance); this.next.evaluate(); }
/** * Invoke {@link TestContextManager#beforeTestClass()} and then evaluate * the next {@link Statement} in the execution chain (typically an instance * of {@link org.junit.internal.runners.statements.RunBefores RunBefores}). */ @Override public void evaluate() throws Throwable { this.testContextManager.beforeTestClass(); this.next.evaluate(); }