Refine search
/** * Check whether the test is enabled in the current execution environment. * <p>This prevents classes with a non-matching {@code @IfProfileValue} * annotation from running altogether, even skipping the execution of * {@code prepareTestInstance()} methods in {@code TestExecutionListeners}. * @see ProfileValueUtils#isTestEnabledInThisEnvironment(Class) * @see org.springframework.test.annotation.IfProfileValue * @see org.springframework.test.context.TestExecutionListener */ @Override public void run(RunNotifier notifier) { if (!ProfileValueUtils.isTestEnabledInThisEnvironment(getTestClass().getJavaClass())) { notifier.fireTestIgnored(getDescription()); return; } super.run(notifier); }
@Override protected void runChild(final FrameworkMethod method, final RunNotifier notifier) { synchronized (permitToGo) { if (concurrentTestMethods.contains(method)) { if (invocations.compareAndSet(1, 0)) { runThemAll(concurrentTestMethods, notifier); } } else { super.runChild(method, notifier); } } }
/** * Returns a new fixture to run a particular test {@code method} against. * Default implementation executes the no-argument {@link #createTest()} method. * * @since 4.13 */ protected Object createTest(FrameworkMethod method) throws Exception { return createTest(); }
/** * Adds to {@code errors} for each method annotated with {@code @Test}, * {@code @Before}, or {@code @After} that is not a public, void instance * method with no arguments. * @deprecated */ @Deprecated protected void validateInstanceMethods(List<Throwable> errors) { validatePublicVoidNoArgMethods(After.class, false, errors); validatePublicVoidNoArgMethods(Before.class, false, errors); validateTestMethods(errors); if (computeTestMethods().isEmpty()) { errors.add(new Exception("No runnable methods")); } }
@Override protected void runChild(final FrameworkMethod method, RunNotifier notifier) { Description description = describeChild(method); if (method.getAnnotation(Ignore.class) != null) { notifier.fireTestIgnored(description); } else { runLeaf(methodBlock(method), description, notifier); } }
Statement statement = methodInvoker(method, test); statement = possiblyExpectingExceptions(method, test, statement); statement = withPotentialTimeout(method, test, statement); statement = withBefores(method, test, statement); statement = withAfters(method, test, statement); statement = withRules(method, test, statement); statement = withInterruptIsolation(statement); return statement;
/** * We decorate the super method by reactor setup and teardown. This method is called once per * class. Note that the given reactor strategy decides whether or not the setup and teardown * actually happens at this level. */ @Override public void run(RunNotifier notifier) { LOG.info("running test class {}", getTestClass().getName()); Class<?> testClass = getTestClass().getJavaClass(); try { manager.beforeClass(stagedReactor, testClass); super.run(notifier); } // CHECKSTYLE:SKIP : catch all wanted catch (Throwable e) { // rethrowing the exception does not help, we have to use the notifier here Description description = Description.createSuiteDescription(testClass); notifier.fireTestFailure(new Failure(description, e)); } finally { manager.afterClass(stagedReactor, testClass); } }
@Override public void runChild(FrameworkMethod method, RunNotifier notifier) { MinVersion methodCondition = method.getAnnotation(MinVersion.class); MinVersion classCondition = this.getTestClass().getJavaClass().getAnnotation(MinVersion.class); String versionStr = VersionInfo.getVersion(); int version = VersionUtil.encodeVersion(versionStr); if ( (methodCondition == null || version >= VersionUtil.encodeVersion(methodCondition.value())) && (classCondition == null || version >= VersionUtil.encodeVersion(classCondition.value()))) { super.runChild(method, notifier); } else { notifier.fireTestIgnored(describeChild(method)); } }
@Override protected List<FrameworkMethod> computeTestMethods() { List<FrameworkMethod> testMethods = new ArrayList<FrameworkMethod>(super.computeTestMethods()); List<FrameworkMethod> theoryMethods = getTestClass().getAnnotatedMethods(Theory.class); testMethods.removeAll(theoryMethods); testMethods.addAll(theoryMethods); return testMethods; }
@Override protected List<FrameworkMethod> computeTestMethods() { return computeTestMethodsForClass(getTestClass().getJavaClass(), super.computeTestMethods()); }
testInstance = super.createTest(); } catch (Exception ex) { throw new RuntimeException(ex); List<FrameworkMethod> befores = getTestClass().getAnnotatedMethods(Before.class); for (FrameworkMethod before : befores) { try { List<FrameworkMethod> afters = getTestClass().getAnnotatedMethods(After.class); for (FrameworkMethod after : afters) { try {
public void run(final RunNotifier notifier) { runner.run(notifier); }
@Override public void run(RunNotifier notifier) { if (!suiteRunning) { // initiate bootstrap ONLY if not running as part of a suite. log.info("[BOOTSTRAP] Initiate single test class servers bootstrap for class '{}'.", getTestClass().getName()); ServerBootstrap.ServersRunstateListener runstateListener = new ServerBootstrap(this).runAll(); // This listener must be added only when executing outside the suite. this.listeners.add(runstateListener); // This will block the current thread until all servers are started } super.run(notifier); }
@Override protected Statement methodBlock(FrameworkMethod method) { return super.methodBlock(method); } }
protected Statement withBefores(FrameworkMethod method, Object target, Statement statement) { // init annotated mocks before tests MockitoAnnotations.initMocks(target); return super.withBefores(method, target, statement); } };
@Override protected Statement methodInvoker(final FrameworkMethod method, final Object test) { if (method.getMethod().getParameterTypes().length > 0) { return new Statement() { @Override public void evaluate() throws Throwable { // 1.invoke the method DexClassNode clzNode = new DexClassNode(DexConstants.ACC_PUBLIC, "La;", "Ljava/lang/Object;", null); if (method.isStatic()) { method.invokeExplosively(null, clzNode); } else { method.invokeExplosively(test, clzNode); } // 2. convert and verify TestUtils.translateAndCheck(clzNode); } }; } else { return super.methodInvoker(method, test); } }
@Override protected Statement withAfters(final FrameworkMethod method, Object target, final Statement statement) { final Statement junitStatement = super.withAfters(method, target, statement); return new Statement() { @Override public void evaluate() throws Throwable { junitStatement.evaluate(); } }; }
@Override protected List<FrameworkMethod> getChildren() { return computeTestMethods(); }
/** * We decorate the super method by reactor setup and teardown. This method is called once per * class. Note that the given reactor strategy decides whether or not the setup and teardown * actually happens at this level. */ @Override public void run(RunNotifier notifier) { LOG.info("running test class {}", getTestClass().getName()); Class<?> testClass = getTestClass().getJavaClass(); try { manager.beforeClass(stagedReactor, testClass); super.run(notifier); } // CHECKSTYLE:SKIP : catch all wanted catch (Throwable e) { // rethrowing the exception does not help, we have to use the notifier here Description description = Description.createSuiteDescription(testClass); notifier.fireTestFailure(new Failure(description, e)); } finally { manager.afterClass(stagedReactor, testClass); } }