Search in sources :

Example 1 with AllDefaultPossibilitiesBuilder

use of org.junit.internal.builders.AllDefaultPossibilitiesBuilder 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 AllDefaultPossibilitiesBuilder

use of org.junit.internal.builders.AllDefaultPossibilitiesBuilder in project component-runtime by Talend.

the class MultiEnvironmentsRunnerTest method run.

@org.junit.jupiter.api.Test
void run() throws Throwable {
    STEPS.clear();
    new AllDefaultPossibilitiesBuilder(true).runnerForClass(TheTestModel.class).run(new RunNotifier());
    assertEquals(asList("start>E1", "test1", "test2", "stop>E1", "start>E2", "test1", "test2", "stop>E2"), STEPS);
}
Also used : AllDefaultPossibilitiesBuilder(org.junit.internal.builders.AllDefaultPossibilitiesBuilder) RunNotifier(org.junit.runner.notification.RunNotifier)

Example 3 with AllDefaultPossibilitiesBuilder

use of org.junit.internal.builders.AllDefaultPossibilitiesBuilder in project intellij-community by JetBrains.

the class JUnit46ClassesRequestBuilder method getClassesRequest.

public static Request getClassesRequest(final String suiteName, Class[] classes, Map classMethods, Class category) {
    boolean canUseSuiteMethod = canUseSuiteMethod(classMethods);
    try {
        if (category != null) {
            try {
                Class.forName("org.junit.experimental.categories.Categories");
            } catch (ClassNotFoundException e) {
                throw new RuntimeException("Categories are not available");
            }
        }
        Runner suite;
        if (canUseSuiteMethod) {
            try {
                Class.forName("org.junit.experimental.categories.Categories");
                suite = new IdeaSuite48(collectWrappedRunners(classes), suiteName, category);
            } catch (ClassNotFoundException e) {
                suite = new IdeaSuite(collectWrappedRunners(classes), suiteName);
            }
        } else {
            final AllDefaultPossibilitiesBuilder builder = new AllDefaultPossibilitiesBuilder(canUseSuiteMethod);
            try {
                Class.forName("org.junit.experimental.categories.Categories");
                suite = new IdeaSuite48(builder, classes, suiteName, category);
            } catch (ClassNotFoundException e) {
                suite = new IdeaSuite(builder, classes, suiteName);
            }
        }
        return Request.runner(suite);
    } catch (InitializationError e) {
        throw new RuntimeException(e);
    }
}
Also used : ErrorReportingRunner(org.junit.internal.runners.ErrorReportingRunner) Runner(org.junit.runner.Runner) AllDefaultPossibilitiesBuilder(org.junit.internal.builders.AllDefaultPossibilitiesBuilder) InitializationError(org.junit.runners.model.InitializationError)

Example 4 with AllDefaultPossibilitiesBuilder

use of org.junit.internal.builders.AllDefaultPossibilitiesBuilder 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)

Example 5 with AllDefaultPossibilitiesBuilder

use of org.junit.internal.builders.AllDefaultPossibilitiesBuilder in project component-runtime by Talend.

the class DelegatingRunnerTest method run.

@Test
void run() throws Throwable {
    MyRunner.STEPS.clear();
    new AllDefaultPossibilitiesBuilder(true).runnerForClass(TheTestModel.class).run(new RunNotifier());
    assertEquals(asList("constructor>" + TheTestModel.class.getName(), "run"), MyRunner.STEPS);
}
Also used : AllDefaultPossibilitiesBuilder(org.junit.internal.builders.AllDefaultPossibilitiesBuilder) RunNotifier(org.junit.runner.notification.RunNotifier) Test(org.junit.jupiter.api.Test)

Aggregations

AllDefaultPossibilitiesBuilder (org.junit.internal.builders.AllDefaultPossibilitiesBuilder)5 ErrorReportingRunner (org.junit.internal.runners.ErrorReportingRunner)3 RunNotifier (org.junit.runner.notification.RunNotifier)2 InitializationError (org.junit.runners.model.InitializationError)2 SuiteMethodBuilder (org.junit.internal.builders.SuiteMethodBuilder)1 Test (org.junit.jupiter.api.Test)1 Runner (org.junit.runner.Runner)1