Search in sources :

Example 41 with Description

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

the class SingleMethodTest method eliminateUnnecessaryTreeBranches.

@Test
public void eliminateUnnecessaryTreeBranches() throws Exception {
    Runner runner = Request.aClass(OneTwoSuite.class).filterWith(Description.createTestDescription(TestOne.class, "a")).getRunner();
    Description description = runner.getDescription();
    assertEquals(1, description.getChildren().size());
}
Also used : Runner(org.junit.runner.Runner) Description(org.junit.runner.Description) Test(org.junit.Test)

Example 42 with Description

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

the class ParentRunnerClassLoaderTest method testDescriptionContainCorrectTestClass.

@Test
public void testDescriptionContainCorrectTestClass() throws Exception {
    Class<?> testClassWithOwnClassLoader = wrapToClassLoader(TestWithClassRule.class);
    ParentRunner<?> runner = new BlockJUnit4ClassRunner(testClassWithOwnClassLoader);
    Description description = runner.getDescription();
    assertEquals("ParentRunner accept already instantiate Class<?> with tests, if we lost it instance, and will " + "use Class.forName we can not find test class again, because tests can be " + "located in different ClassLoader", description.getTestClass(), testClassWithOwnClassLoader);
}
Also used : Description(org.junit.runner.Description) BlockJUnit4ClassRunner(org.junit.runners.BlockJUnit4ClassRunner) Test(org.junit.Test)

Example 43 with Description

use of org.junit.runner.Description 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 44 with Description

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

the class MaxStarterTest method preferFast.

@Test
public void preferFast() {
    Request request = Request.aClass(TwoUnEqualTests.class);
    fMax.run(request);
    Description thing = fMax.sortedLeavesForTest(request).get(1);
    assertEquals(Description.createTestDescription(TwoUnEqualTests.class, "slow"), thing);
}
Also used : Description(org.junit.runner.Description) Request(org.junit.runner.Request) Test(org.junit.Test)

Example 45 with Description

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

the class MaxStarterTest method preferRecentlyFailed.

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

Aggregations

Description (org.junit.runner.Description)190 Test (org.junit.Test)84 Failure (org.junit.runner.notification.Failure)42 Result (org.junit.runner.Result)27 ArrayList (java.util.ArrayList)20 Request (org.junit.runner.Request)20 RunListener (org.junit.runner.notification.RunListener)20 JUnitCore (org.junit.runner.JUnitCore)16 IOException (java.io.IOException)14 Method (java.lang.reflect.Method)12 Filter (org.junit.runner.manipulation.Filter)12 JUnit4TestListener (com.intellij.junit4.JUnit4TestListener)10 Runner (org.junit.runner.Runner)9 RunNotifier (org.junit.runner.notification.RunNotifier)9 ComparisonFailure (org.junit.ComparisonFailure)8 Statement (org.junit.runners.model.Statement)8 InOrder (org.mockito.InOrder)8 TestSuiteModel (com.google.testing.junit.runner.model.TestSuiteModel)7 Subscribe (com.google.common.eventbus.Subscribe)6 Step (gherkin.formatter.model.Step)6