Search in sources :

Example 51 with Runner

use of org.junit.runner.Runner in project reddeer by eclipse.

the class RedDeerSuiteTest method testSingleTestWithoutConfiguration.

@Test
public void testSingleTestWithoutConfiguration() throws InitializationError {
    System.setProperty(RedDeerProperties.CONFIG_FILE.getName(), REDDEER_SUITE_CONFIG);
    SuiteConfiguration config = new SuiteConfiguration(SimpleTestClass.class);
    List<Runner> runners = RedDeerSuite.createSuites(SimpleTestClass.class, config);
    assertThat(runners.size(), is(1));
    assertThat(runners, hasItem(new NamedSuiteMatcher("no-configuration")));
}
Also used : Runner(org.junit.runner.Runner) SuiteConfiguration(org.eclipse.reddeer.junit.internal.configuration.SuiteConfiguration) Test(org.junit.Test)

Example 52 with Runner

use of org.junit.runner.Runner in project reddeer by eclipse.

the class RedDeerSuiteTest method getTestCount.

private int getTestCount(@SuppressWarnings("rawtypes") Class suiteClass) throws Throwable {
    SuiteConfiguration config = new SuiteConfiguration(suiteClass);
    List<Runner> runners = RedDeerSuite.createSuites(suiteClass, config);
    short testCount = 0;
    for (Runner runner : runners) {
        if (!(runner instanceof TestsWithoutExecutionSuite)) {
            testCount += runner.getDescription().testCount();
        }
    }
    return testCount;
}
Also used : Runner(org.junit.runner.Runner) SuiteConfiguration(org.eclipse.reddeer.junit.internal.configuration.SuiteConfiguration) TestsWithoutExecutionSuite(org.eclipse.reddeer.junit.internal.runner.TestsWithoutExecutionSuite)

Example 53 with Runner

use of org.junit.runner.Runner in project maven-surefire by apache.

the class JUnit4RunListenerTest method testTestStarted.

public void testTestStarted() {
    RunListener jUnit4TestSetReporter = new JUnit4RunListener(new MockReporter());
    Runner junitTestRunner = Request.classes("abc", STest1.class, STest2.class).getRunner();
    RunNotifier runNotifier = new RunNotifier();
    runNotifier.addListener(jUnit4TestSetReporter);
    junitTestRunner.run(runNotifier);
}
Also used : Runner(org.junit.runner.Runner) RunNotifier(org.junit.runner.notification.RunNotifier) RunListener(org.junit.runner.notification.RunListener)

Example 54 with Runner

use of org.junit.runner.Runner in project maven-surefire by apache.

the class JUnit4Provider method execute.

private static void execute(Class<?> testClass, Notifier notifier, Filter filter) {
    final int classModifiers = testClass.getModifiers();
    if (!isAbstract(classModifiers) && !isInterface(classModifiers)) {
        Request request = aClass(testClass);
        if (filter != null) {
            request = request.filterWith(filter);
        }
        Runner runner = request.getRunner();
        if (countTestsInRunner(runner.getDescription()) != 0) {
            runner.run(notifier);
        }
    }
}
Also used : Runner(org.junit.runner.Runner) TestRequest(org.apache.maven.surefire.api.testset.TestRequest) Request(org.junit.runner.Request)

Example 55 with Runner

use of org.junit.runner.Runner in project vividus by vividus-framework.

the class AbstractTestRunner method main.

@SuppressWarnings("NoMainMethodInAbstractClass")
public static void main(String[] args) throws InitializationError {
    Runner runner = new JUnit4(runnerClass);
    Result result = new JUnitCore().run(runner);
    int exitCode;
    if (result.getFailureCount() > 0) {
        Logger logger = LoggerFactory.getLogger(runnerClass);
        result.getFailures().forEach(f -> {
            logger.error("Failure: {}", f);
            logger.atError().addArgument(f::getTrace).log("{}");
        });
        exitCode = ERROR_EXIT_CODE;
    } else {
        exitCode = calculateExitCode(BeanFactory.getBean(IRunStatusProvider.class).getRunStatus());
    }
    System.exit(exitCode);
}
Also used : Runner(org.junit.runner.Runner) JUnitCore(org.junit.runner.JUnitCore) TestInfoLogger(org.vividus.log.TestInfoLogger) Logger(org.slf4j.Logger) IRunStatusProvider(org.vividus.IRunStatusProvider) JUnit4(org.junit.runners.JUnit4) Result(org.junit.runner.Result)

Aggregations

Runner (org.junit.runner.Runner)106 Test (org.junit.Test)39 RunNotifier (org.junit.runner.notification.RunNotifier)22 ArrayList (java.util.ArrayList)18 Description (org.junit.runner.Description)18 JUnitCore (org.junit.runner.JUnitCore)18 ParentRunner (org.junit.runners.ParentRunner)16 Request (org.junit.runner.Request)15 Result (org.junit.runner.Result)13 Filter (org.junit.runner.manipulation.Filter)12 NoTestsRemainException (org.junit.runner.manipulation.NoTestsRemainException)12 InitializationError (org.junit.runners.model.InitializationError)10 Method (java.lang.reflect.Method)9 JUnit4ParameterizedTest (androidx.test.testing.fixtures.JUnit4ParameterizedTest)7 SuiteConfiguration (org.eclipse.reddeer.junit.internal.configuration.SuiteConfiguration)7 Failure (org.junit.runner.notification.Failure)7 ErrorReportingRunner (org.junit.internal.runners.ErrorReportingRunner)6 Filterable (org.junit.runner.manipulation.Filterable)6 BlockJUnit4ClassRunner (org.junit.runners.BlockJUnit4ClassRunner)6 Field (java.lang.reflect.Field)5