Search in sources :

Example 1 with ErrorReportingRunner

use of org.junit.internal.runners.ErrorReportingRunner in project intellij-community by JetBrains.

the class JUnit46ClassesRequestBuilder method collectWrappedRunners.

private static List collectWrappedRunners(Class[] classes) throws InitializationError {
    final List runners = new ArrayList();
    final List nonSuiteClasses = new ArrayList();
    final SuiteMethodBuilder suiteMethodBuilder = new SuiteMethodBuilder();
    for (int i = 0, length = classes.length; i < length; i++) {
        Class aClass = classes[i];
        if (suiteMethodBuilder.hasSuiteMethod(aClass)) {
            try {
                runners.add(new ClassAwareSuiteMethod(aClass));
            } catch (Throwable throwable) {
                runners.add(new ErrorReportingRunner(aClass, throwable));
            }
        } else {
            nonSuiteClasses.add(aClass);
        }
    }
    runners.addAll(new AllDefaultPossibilitiesBuilder(false).runners(null, (Class[]) nonSuiteClasses.toArray(new Class[nonSuiteClasses.size()])));
    return runners;
}
Also used : SuiteMethodBuilder(org.junit.internal.builders.SuiteMethodBuilder) AllDefaultPossibilitiesBuilder(org.junit.internal.builders.AllDefaultPossibilitiesBuilder) ErrorReportingRunner(org.junit.internal.runners.ErrorReportingRunner)

Example 2 with ErrorReportingRunner

use of org.junit.internal.runners.ErrorReportingRunner in project jena by apache.

the class ManifestSuite method oneManifest.

private Runner oneManifest(final Manifest manifest, List<Runner> r) {
    // Recurse
    for (Iterator<String> iter = manifest.includedManifests(); iter.hasNext(); ) {
        try {
            r.add(oneManifest(new Manifest(iter.next()), new ArrayList<Runner>()));
        } catch (JenaException ex) {
            r.add(new ErrorReportingRunner(null, ex));
        }
    }
    itemHandler.setTestRunnerList(r);
    manifest.apply(itemHandler);
    try {
        return new Suite((Class<?>) null, r) {

            @Override
            protected String getName() {
                return manifest.getName();
            }
        };
    } catch (InitializationError e) {
        return new ErrorReportingRunner(null, e);
    }
}
Also used : Suite(org.junit.runners.Suite) JenaException(org.apache.jena.shared.JenaException) InitializationError(org.junit.runners.model.InitializationError) ArrayList(java.util.ArrayList) ErrorReportingRunner(org.junit.internal.runners.ErrorReportingRunner)

Example 3 with ErrorReportingRunner

use of org.junit.internal.runners.ErrorReportingRunner in project junit4 by junit-team.

the class FilterRequest method getRunner.

@Override
public Runner getRunner() {
    try {
        Runner runner = request.getRunner();
        fFilter.apply(runner);
        return runner;
    } catch (NoTestsRemainException e) {
        return new ErrorReportingRunner(Filter.class, new Exception(String.format("No tests found matching %s from %s", fFilter.describe(), request.toString())));
    }
}
Also used : ErrorReportingRunner(org.junit.internal.runners.ErrorReportingRunner) Runner(org.junit.runner.Runner) Filter(org.junit.runner.manipulation.Filter) NoTestsRemainException(org.junit.runner.manipulation.NoTestsRemainException) ErrorReportingRunner(org.junit.internal.runners.ErrorReportingRunner) NoTestsRemainException(org.junit.runner.manipulation.NoTestsRemainException)

Example 4 with ErrorReportingRunner

use of org.junit.internal.runners.ErrorReportingRunner in project dspot by STAMP-project.

the class MethodFilterTest method testNoMatching.

@Test
public void testNoMatching() throws Exception {
    // contains 0 testRunTestClass
    Request request = Request.classes(MethodFilterTest.class);
    request = request.filterWith(new MethodFilter(Collections.singletonList("testRunTestClass")));
    assertTrue(request.getRunner() instanceof ErrorReportingRunner);
}
Also used : Request(org.junit.runner.Request) ErrorReportingRunner(org.junit.internal.runners.ErrorReportingRunner) MockitoTestRunnerTest(fr.inria.stamp.test.runner.MockitoTestRunnerTest) DefaultTestRunnerTest(fr.inria.stamp.test.runner.DefaultTestRunnerTest) Test(org.junit.Test)

Example 5 with ErrorReportingRunner

use of org.junit.internal.runners.ErrorReportingRunner in project junit4 by junit-team.

the class Request method classes.

/**
 * Create a <code>Request</code> that, when processed, will run all the tests
 * in a set of classes.
 *
 * @param computer Helps construct Runners from classes
 * @param classes the classes containing the tests
 * @return a <code>Request</code> that will cause all tests in the classes to be run
 */
public static Request classes(Computer computer, Class<?>... classes) {
    try {
        AllDefaultPossibilitiesBuilder builder = new AllDefaultPossibilitiesBuilder();
        Runner suite = computer.getSuite(builder, classes);
        return runner(suite);
    } catch (InitializationError e) {
        return runner(new ErrorReportingRunner(e, classes));
    }
}
Also used : ErrorReportingRunner(org.junit.internal.runners.ErrorReportingRunner) AllDefaultPossibilitiesBuilder(org.junit.internal.builders.AllDefaultPossibilitiesBuilder) InitializationError(org.junit.runners.model.InitializationError) ErrorReportingRunner(org.junit.internal.runners.ErrorReportingRunner)

Aggregations

ErrorReportingRunner (org.junit.internal.runners.ErrorReportingRunner)5 AllDefaultPossibilitiesBuilder (org.junit.internal.builders.AllDefaultPossibilitiesBuilder)2 InitializationError (org.junit.runners.model.InitializationError)2 DefaultTestRunnerTest (fr.inria.stamp.test.runner.DefaultTestRunnerTest)1 MockitoTestRunnerTest (fr.inria.stamp.test.runner.MockitoTestRunnerTest)1 ArrayList (java.util.ArrayList)1 JenaException (org.apache.jena.shared.JenaException)1 Test (org.junit.Test)1 SuiteMethodBuilder (org.junit.internal.builders.SuiteMethodBuilder)1 Request (org.junit.runner.Request)1 Runner (org.junit.runner.Runner)1 Filter (org.junit.runner.manipulation.Filter)1 NoTestsRemainException (org.junit.runner.manipulation.NoTestsRemainException)1 Suite (org.junit.runners.Suite)1