Search in sources :

Example 46 with Request

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

the class MaxStarterTest method maxShouldSkipMalformedJUnit38Classes.

@Test
public void maxShouldSkipMalformedJUnit38Classes() {
    Request request = Request.aClass(MalformedJUnit38Test.class);
    fMax.run(request);
}
Also used : Request(org.junit.runner.Request) Test(org.junit.Test)

Example 47 with Request

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

the class MaxStarterTest method assertFilterLeavesTestUnscathed.

private void assertFilterLeavesTestUnscathed(Class<?> testClass) {
    Request oneClass = Request.aClass(testClass);
    Request filtered = oneClass.filterWith(new Filter() {

        @Override
        public boolean shouldRun(Description description) {
            return true;
        }

        @Override
        public String describe() {
            return "Everything";
        }
    });
    int filterCount = filtered.getRunner().testCount();
    int coreCount = oneClass.getRunner().testCount();
    assertEquals("Counts match up in " + testClass, coreCount, filterCount);
}
Also used : Description(org.junit.runner.Description) Filter(org.junit.runner.manipulation.Filter) Request(org.junit.runner.Request) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString)

Example 48 with Request

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

the class MaxStarterTest method preferNewTests.

@Test
public void preferNewTests() {
    Request one = Request.method(TwoTests.class, "succeed");
    fMax.run(one);
    Request two = Request.aClass(TwoTests.class);
    List<Description> things = fMax.sortedLeavesForTest(two);
    Description dontSucceed = Description.createTestDescription(TwoTests.class, "dontSucceed");
    assertEquals(dontSucceed, things.get(0));
    assertEquals(2, things.size());
}
Also used : Description(org.junit.runner.Description) Request(org.junit.runner.Request) Test(org.junit.Test)

Example 49 with Request

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

the class MaxStarterTest method twoTestsNotRunComeBackInRandomOrder.

@Test
public void twoTestsNotRunComeBackInRandomOrder() {
    Request request = Request.aClass(TwoTests.class);
    List<Description> things = fMax.sortedLeavesForTest(request);
    Description succeed = Description.createTestDescription(TwoTests.class, "succeed");
    Description dontSucceed = Description.createTestDescription(TwoTests.class, "dontSucceed");
    assertTrue(things.contains(succeed));
    assertTrue(things.contains(dontSucceed));
    assertEquals(2, things.size());
}
Also used : Description(org.junit.runner.Description) Request(org.junit.runner.Request) Test(org.junit.Test)

Example 50 with Request

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

the class MaxStarterTest method preferNewTestsOverTestsThatFailed.

// This covers a seemingly-unlikely case, where you had a test that failed
// on the
// last run and you also introduced new tests. In such a case it pretty much
// doesn't matter
// which order they run, you just want them both to be early in the sequence
@Test
public void preferNewTestsOverTestsThatFailed() {
    Request one = Request.method(TwoTests.class, "dontSucceed");
    fMax.run(one);
    Request two = Request.aClass(TwoTests.class);
    List<Description> things = fMax.sortedLeavesForTest(two);
    Description succeed = Description.createTestDescription(TwoTests.class, "succeed");
    assertEquals(succeed, things.get(0));
    assertEquals(2, things.size());
}
Also used : Description(org.junit.runner.Description) Request(org.junit.runner.Request) 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