Search in sources :

Example 21 with Runner

use of org.junit.runner.Runner 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 22 with Runner

use of org.junit.runner.Runner in project junit4 by junit-team.

the class ParentRunnerFilteringTest method testSuiteFilteringWithUnmodifiableChildList.

@Test
public void testSuiteFilteringWithUnmodifiableChildList() throws Exception {
    Runner runner = Request.aClass(ExampleSuiteWithUnmodifiableChildList.class).getRunner();
    Filter filter = notThisMethodName("test1");
    try {
        filter.apply(runner);
    } catch (NoTestsRemainException e) {
        return;
    }
    fail("Expected 'NoTestsRemainException' due to complete filtering");
}
Also used : Runner(org.junit.runner.Runner) Filter(org.junit.runner.manipulation.Filter) NoTestsRemainException(org.junit.runner.manipulation.NoTestsRemainException) Test(org.junit.Test)

Example 23 with Runner

use of org.junit.runner.Runner in project junit4 by junit-team.

the class ParentRunnerFilteringTest method testSuiteFiltering.

@Test
public void testSuiteFiltering() throws Exception {
    Runner runner = Request.aClass(ExampleSuite.class).getRunner();
    Filter filter = notThisMethodName("test1");
    try {
        filter.apply(runner);
    } catch (NoTestsRemainException e) {
        return;
    }
    fail("Expected 'NoTestsRemainException' due to complete filtering");
}
Also used : Runner(org.junit.runner.Runner) Filter(org.junit.runner.manipulation.Filter) NoTestsRemainException(org.junit.runner.manipulation.NoTestsRemainException) Test(org.junit.Test)

Example 24 with Runner

use of org.junit.runner.Runner in project junit4 by junit-team.

the class ParameterizedTestTest method plansNamedCorrectly.

@Test
public void plansNamedCorrectly() throws Exception {
    Runner runner = Request.aClass(AdditionTest.class).getRunner();
    Description description = runner.getDescription();
    assertEquals("[2: 3 + 2 = 5]", description.getChildren().get(2).getDisplayName());
}
Also used : Runner(org.junit.runner.Runner) Description(org.junit.runner.Description) Test(org.junit.Test)

Example 25 with Runner

use of org.junit.runner.Runner in project junit4 by junit-team.

the class SingleMethodTest method oneTimeSetup.

@Test
public void oneTimeSetup() throws Exception {
    count = 0;
    Runner runner = Request.method(OneTimeSetup.class, "one").getRunner();
    Result result = new JUnitCore().run(runner);
    assertEquals(1, count);
    assertEquals(1, result.getRunCount());
}
Also used : Runner(org.junit.runner.Runner) JUnitCore(org.junit.runner.JUnitCore) Result(org.junit.runner.Result) Test(org.junit.Test)

Aggregations

Runner (org.junit.runner.Runner)64 Test (org.junit.Test)21 Description (org.junit.runner.Description)14 ParentRunner (org.junit.runners.ParentRunner)13 ArrayList (java.util.ArrayList)12 JUnitCore (org.junit.runner.JUnitCore)11 Request (org.junit.runner.Request)11 RunNotifier (org.junit.runner.notification.RunNotifier)11 Filter (org.junit.runner.manipulation.Filter)10 NoTestsRemainException (org.junit.runner.manipulation.NoTestsRemainException)9 Result (org.junit.runner.Result)8 Method (java.lang.reflect.Method)7 Failure (org.junit.runner.notification.Failure)7 InitializationError (org.junit.runners.model.InitializationError)7 JUnit38ClassRunner (org.junit.internal.runners.JUnit38ClassRunner)5 RunnerSpy (org.junit.runner.RunnerSpy)5 LinkedList (java.util.LinkedList)4 BlockJUnit4ClassRunner (org.junit.runners.BlockJUnit4ClassRunner)4 File (java.io.File)3 ImmutableMap (com.google.common.collect.ImmutableMap)2