Search in sources :

Example 6 with Request

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

the class ParentRunnerTest method assertClassHasFailureMessage.

private void assertClassHasFailureMessage(Class<?> klass, String message) {
    JUnitCore junitCore = new JUnitCore();
    Request request = Request.aClass(klass);
    Result result = junitCore.run(request);
    assertThat(result.getFailureCount(), is(1));
    assertThat(result.getFailures().get(0).getMessage(), containsString(message));
}
Also used : JUnitCore(org.junit.runner.JUnitCore) Request(org.junit.runner.Request) Result(org.junit.runner.Result)

Example 7 with Request

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

the class ParentRunnerFilteringTest method testRunSuiteFiltering.

@Test
public void testRunSuiteFiltering() throws Exception {
    Request request = Request.aClass(ExampleSuite.class);
    Request requestFiltered = request.filterWith(notThisMethodName("test1"));
    assertThat(testResult(requestFiltered), hasSingleFailureContaining("don't run method name: test1"));
}
Also used : Request(org.junit.runner.Request) Test(org.junit.Test)

Example 8 with Request

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

the class ParentRunnerFilteringTest method testCountClassFiltering.

@Test
public void testCountClassFiltering() throws Exception {
    JUnitCore junitCore = new JUnitCore();
    Request request = Request.aClass(ExampleTest.class);
    CountingFilter countingFilter = new CountingFilter();
    Request requestFiltered = request.filterWith(countingFilter);
    Result result = junitCore.run(requestFiltered);
    assertEquals(1, result.getRunCount());
    assertEquals(0, result.getFailureCount());
    Description desc = createTestDescription(ExampleTest.class, "test1");
    assertEquals(1, countingFilter.getCount(desc));
}
Also used : Description.createTestDescription(org.junit.runner.Description.createTestDescription) Description(org.junit.runner.Description) Description.createSuiteDescription(org.junit.runner.Description.createSuiteDescription) JUnitCore(org.junit.runner.JUnitCore) Request(org.junit.runner.Request) Result(org.junit.runner.Result) PrintableResult.testResult(org.junit.experimental.results.PrintableResult.testResult) Test(org.junit.Test)

Example 9 with Request

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

the class JUnit38SortingTest method preferRecentlyFailed38Test.

@Test
public void preferRecentlyFailed38Test() {
    Request request = Request.classes(JUnit4Test.class, JUnit38Test.class);
    fMax.run(request);
    List<Description> tests = fMax.sortedLeavesForTest(request);
    Description dontSucceed = Description.createTestDescription(JUnit38Test.class, "testFails");
    assertEquals(dontSucceed, tests.get(0));
}
Also used : Description(org.junit.runner.Description) Request(org.junit.runner.Request) Test(org.junit.Test)

Example 10 with Request

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

the class MaxStarterTest method correctErrorFromMalformedTest.

@Test
public void correctErrorFromMalformedTest() {
    Request request = Request.aClass(MalformedJUnit38TestMethod.class);
    JUnitCore core = new JUnitCore();
    Request sorted = fMax.sortRequest(request);
    Runner runner = sorted.getRunner();
    Result result = core.run(runner);
    Failure failure = result.getFailures().get(0);
    assertThat(failure.toString(), containsString("MalformedJUnit38TestMethod"));
    assertThat(failure.toString(), containsString("testNothing"));
    assertThat(failure.toString(), containsString("isn't public"));
}
Also used : JUnit38ClassRunner(org.junit.internal.runners.JUnit38ClassRunner) Runner(org.junit.runner.Runner) JUnitCore(org.junit.runner.JUnitCore) Request(org.junit.runner.Request) Failure(org.junit.runner.notification.Failure) Result(org.junit.runner.Result) Test(org.junit.Test)

Aggregations

Request (org.junit.runner.Request)54 Test (org.junit.Test)37 JUnitCore (org.junit.runner.JUnitCore)32 Result (org.junit.runner.Result)22 Description (org.junit.runner.Description)20 TestSuiteModel (com.google.testing.junit.runner.model.TestSuiteModel)8 Runner (org.junit.runner.Runner)8 PrintableResult.testResult (org.junit.experimental.results.PrintableResult.testResult)7 ByteArrayOutputStream (java.io.ByteArrayOutputStream)6 RunListener (org.junit.runner.notification.RunListener)6 OutputStream (java.io.OutputStream)5 CategoryFilter (org.junit.experimental.categories.Categories.CategoryFilter)5 Filter (org.junit.runner.manipulation.Filter)5 Failure (org.junit.runner.notification.Failure)5 IOException (java.io.IOException)4 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)4 InOrder (org.mockito.InOrder)4 ArrayList (java.util.ArrayList)3 Computer (org.junit.runner.Computer)3 TestNode (com.google.testing.junit.runner.model.TestNode)2