use of org.junit.runner.Description 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));
}
use of org.junit.runner.Description in project junit4 by junit-team.
the class ListenerTest method notifyListenersInTheOrderInWhichTheyAreAdded.
@Test
public void notifyListenersInTheOrderInWhichTheyAreAdded() {
JUnitCore core = new JUnitCore();
log = "";
core.addListener(new RunListener() {
@Override
public void testRunStarted(Description description) throws Exception {
log += "first ";
}
});
core.addListener(new RunListener() {
@Override
public void testRunStarted(Description description) throws Exception {
log += "second ";
}
});
core.run(OneTest.class);
assertEquals("first second ", log);
}
use of org.junit.runner.Description in project junit4 by junit-team.
the class RunnerTest method testFinished.
@Test
public void testFinished() {
JUnitCore runner = new JUnitCore();
wasRun = false;
RunListener listener = new MyListener() {
@Override
public void testFinished(Description description) {
wasRun = true;
}
};
runner.addListener(listener);
runner.run(NewExample.class);
assertTrue(wasRun);
}
use of org.junit.runner.Description in project junit4 by junit-team.
the class JUnit38ClassRunnerTest method testListener.
@Test
public void testListener() throws Exception {
JUnitCore runner = new JUnitCore();
RunListener listener = new RunListener() {
@Override
public void testStarted(Description description) {
assertEquals(Description.createTestDescription(OneTest.class, "testOne"), description);
count++;
}
};
runner.addListener(listener);
count = 0;
Result result = runner.run(OneTest.class);
assertEquals(1, count);
assertEquals(1, result.getRunCount());
}
use of org.junit.runner.Description in project junit4 by junit-team.
the class SingleMethodTest method filteringAwayEverythingThrowsException.
@Test(expected = NoTestsRemainException.class)
public void filteringAwayEverythingThrowsException() throws NoTestsRemainException {
Filterable runner = (Filterable) Request.aClass(OneTimeSetup.class).getRunner();
runner.filter(new Filter() {
@Override
public boolean shouldRun(Description description) {
return false;
}
@Override
public String describe() {
return null;
}
});
}
Aggregations