use of junit.framework.TestResult in project junit4 by junit-team.
the class ForwardCompatibilityTest method testBeforeAndAfterClass.
public void testBeforeAndAfterClass() {
log = "";
TestResult result = new TestResult();
junit.framework.Test adapter = new JUnit4TestAdapter(BeforeClassTest.class);
adapter.run(result);
assertEquals("before class before test after before test after after class ", log);
}
use of junit.framework.TestResult in project junit4 by junit-team.
the class ForwardCompatibilityTest method testRunWithClass.
public void testRunWithClass() {
wasRun = false;
TestResult result = new TestResult();
junit.framework.Test adapter = new JUnit4TestAdapter(NoTests.class);
adapter.run(result);
assertTrue(wasRun);
}
use of junit.framework.TestResult in project junit4 by junit-team.
the class ForwardCompatibilityPrintingTest method testErrorAdapted.
public void testErrorAdapted() {
ByteArrayOutputStream output = new ByteArrayOutputStream();
TestRunner runner = new TestRunner(new TestResultPrinter(new PrintStream(output)));
String expected = expected(new String[] { ".E", "Time: 0", "Errors here", "", "FAILURES!!!", "Tests run: 1, Failures: 0, Errors: 1", "" });
ResultPrinter printer = new TestResultPrinter(new PrintStream(output)) {
@Override
public void printErrors(TestResult result) {
getWriter().println("Errors here");
}
};
runner.setPrinter(printer);
runner.doRun(new JUnit4TestAdapter(ATest.class));
assertEquals(expected, output.toString());
}
use of junit.framework.TestResult in project junit4 by junit-team.
the class ForwardCompatibilityPrintingTest method testError.
public void testError() {
ByteArrayOutputStream output = new ByteArrayOutputStream();
TestRunner runner = new TestRunner(new TestResultPrinter(new PrintStream(output)));
String expected = expected(new String[] { ".E", "Time: 0", "Errors here", "", "FAILURES!!!", "Tests run: 1, Failures: 0, Errors: 1", "" });
ResultPrinter printer = new TestResultPrinter(new PrintStream(output)) {
@Override
public void printErrors(TestResult result) {
getWriter().println("Errors here");
}
};
runner.setPrinter(printer);
TestSuite suite = new TestSuite();
suite.addTest(new TestCase() {
@Override
public void runTest() throws Exception {
throw new Exception();
}
});
runner.doRun(suite);
assertEquals(expected, output.toString());
}
use of junit.framework.TestResult in project junit4 by junit-team.
the class JUnit4TestAdapterTest method doTest.
private static void doTest(Class<?> clazz) {
// JUnit 4 runner:
Result result = JUnitCore.runClasses(clazz);
assertEquals(1, result.getRunCount());
assertEquals(0, result.getFailureCount());
assertEquals(0, result.getIgnoreCount());
// JUnit 3 runner:
TestResult testResult = new TestResult();
new JUnit4TestAdapter(clazz).run(testResult);
assertEquals(1, testResult.runCount());
assertEquals(0, testResult.failureCount());
assertEquals(Collections.emptyList(), Collections.list(testResult.errors()));
}
Aggregations