public ExtendedFrameworkMethod(FrameworkMethod delegatee, Ignore virtualIgnore, FailureExpected failureExpectedAnnotation) { super( delegatee.getMethod() ); this.delegatee = delegatee; this.virtualIgnore = virtualIgnore; this.failureExpectedAnnotation = failureExpectedAnnotation; }
/** * 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()); }
/** * 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()); }
@Override protected void invokeMethod(FrameworkMethod method) throws Throwable { int paramCount = method.getMethod().getParameterTypes().length; method.invokeExplosively(null, paramCount == 0 ? (Object[]) null : parameters); } }
@Override protected void invokeMethod(FrameworkMethod method) throws Throwable { int paramCount = method.getMethod().getParameterTypes().length; method.invokeExplosively(null, paramCount == 0 ? (Object[]) null : parameters); } }
private boolean nullsOk() { Theory annotation = testMethod.getMethod().getAnnotation( Theory.class); if (annotation == null) { return false; } return annotation.nullsAccepted(); }
private boolean nullsOk() { Theory annotation = fTestMethod.getMethod().getAnnotation( Theory.class); if (annotation == null) { return false; } return annotation.nullsAccepted(); }
/** * Wrap the supplied {@link Statement} with a {@code RunAfterTestExecutionCallbacks} * statement, thus preserving the default functionality while adding support for the * Spring TestContext Framework. * @see RunAfterTestExecutionCallbacks */ protected Statement withAfterTestExecutionCallbacks(FrameworkMethod frameworkMethod, Object testInstance, Statement statement) { return new RunAfterTestExecutionCallbacks(statement, testInstance, frameworkMethod.getMethod(), getTestContextManager()); }
/** * Wrap the supplied {@link Statement} with a {@code RunBeforeTestExecutionCallbacks} * statement, thus preserving the default functionality while adding support for the * Spring TestContext Framework. * @see RunBeforeTestExecutionCallbacks */ protected Statement withBeforeTestExecutionCallbacks(FrameworkMethod frameworkMethod, Object testInstance, Statement statement) { return new RunBeforeTestExecutionCallbacks(statement, testInstance, frameworkMethod.getMethod(), getTestContextManager()); }
/** * Extract a nice test name representation for display * * @param frameworkMethod The test method. * * @return The display representation */ public static String extractTestName(FrameworkMethod frameworkMethod) { return frameworkMethod.getMethod().getDeclaringClass().getName() + '#' + frameworkMethod.getName(); }
/** * Returns the {@link FrameworkMethod} object for the given method in the provided class loader. */ private static FrameworkMethod getFrameworkMethodInClassLoader( FrameworkMethod method, ClassLoader classLoader) throws ClassNotFoundException, NoSuchMethodException { Method methodInClassLoader = getMethodInClassLoader(method.getMethod(), classLoader); if (methodInClassLoader.equals(method.getMethod())) { // The method was already loaded in the right class loader, return it as is. return method; } return new FrameworkMethod(methodInClassLoader); }
/** * 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())); }
private static FrameworkMethod getParametersMethod(TestClass testClass, ClassLoader classLoader) throws Exception { List<FrameworkMethod> methods = testClass.getAnnotatedMethods(Parameters.class); for (FrameworkMethod each : methods) { int modifiers = each.getMethod().getModifiers(); if (Modifier.isStatic(modifiers) && Modifier.isPublic(modifiers)) { return getFrameworkMethodInClassLoader(each, classLoader); } } throw new Exception("No public static parameters method on class " + testClass.getName()); }
/** * Wrap the {@link Statement} returned by the parent implementation with a * {@code RunBeforeTestMethodCallbacks} statement, thus preserving the * default functionality while adding support for the Spring TestContext * Framework. * @see RunBeforeTestMethodCallbacks */ @Override protected Statement withBefores(FrameworkMethod frameworkMethod, Object testInstance, Statement statement) { Statement junitBefores = super.withBefores(frameworkMethod, testInstance, statement); return new RunBeforeTestMethodCallbacks(junitBefores, testInstance, frameworkMethod.getMethod(), getTestContextManager()); }
/** * Wrap the {@link Statement} returned by the parent implementation with a * {@code RunAfterTestMethodCallbacks} statement, thus preserving the * default functionality while adding support for the Spring TestContext * Framework. * @see RunAfterTestMethodCallbacks */ @Override protected Statement withAfters(FrameworkMethod frameworkMethod, Object testInstance, Statement statement) { Statement junitAfters = super.withAfters(frameworkMethod, testInstance, statement); return new RunAfterTestMethodCallbacks(junitAfters, testInstance, frameworkMethod.getMethod(), getTestContextManager()); }
@Override protected boolean isTestMethodIgnored(FrameworkMethod frameworkMethod) { if (!isPrereuisitSatisfied(frameworkMethod.getMethod())) { return true; } return super.isTestMethodIgnored(frameworkMethod); } }
private void validatePublicStaticVoidMethods( Class<? extends Annotation> annotation, Integer parameterCount, List<Throwable> errors) { List<FrameworkMethod> methods = getTestClass().getAnnotatedMethods(annotation); for (FrameworkMethod fm : methods) { fm.validatePublicVoid(true, errors); if (parameterCount != null) { int methodParameterCount = fm.getMethod().getParameterTypes().length; if (methodParameterCount != 0 && methodParameterCount != parameterCount) { errors.add(new Exception("Method " + fm.getName() + "() should have 0 or " + parameterCount + " parameter(s)")); } } } }
@Override public void evaluate() throws Throwable { runWithAssignment(Assignments.allUnassigned( fTestMethod.getMethod(), getTestClass())); if (successes == 0) { Assert .fail("Never found parameters that satisfied method assumptions. Violated assumptions: " + fInvalidParameters); } }
@Override public void evaluate() throws Throwable { runWithAssignment(Assignments.allUnassigned( testMethod.getMethod(), getTestClass())); //if this test method is not annotated with Theory, then no successes is a valid case boolean hasTheoryAnnotation = testMethod.getAnnotation(Theory.class) != null; if (successes == 0 && hasTheoryAnnotation) { Assert .fail("Never found parameters that satisfied method assumptions. Violated assumptions: " + fInvalidParameters); } }