use of junit.framework.TestResult in project junit4 by junit-team.
the class RepeatedTestTest method testRepeatedOnce.
public void testRepeatedOnce() {
Test test = new RepeatedTest(fSuite, 1);
assertEquals(2, test.countTestCases());
TestResult result = new TestResult();
test.run(result);
assertEquals(2, result.runCount());
}
use of junit.framework.TestResult in project junit4 by junit-team.
the class TextFeedbackTest method testFailure.
public void testFailure() {
String expected = expected(new String[] { ".F", "Time: 0", "Failures here", "", "FAILURES!!!", "Tests run: 1, Failures: 1, Errors: 0", "" });
ResultPrinter printer = new TestResultPrinter(new PrintStream(output)) {
@Override
public void printFailures(TestResult result) {
getWriter().println("Failures here");
}
};
runner.setPrinter(printer);
TestSuite suite = new TestSuite();
suite.addTest(new TestCase() {
@Override
public void runTest() {
throw new AssertionFailedError();
}
});
runner.doRun(suite);
assertEquals(expected, output.toString());
}
use of junit.framework.TestResult in project junit4 by junit-team.
the class ForwardCompatibilityTest method testInvalidMethod.
public void testInvalidMethod() {
TestResult result = new TestResult();
junit.framework.Test adapter = new JUnit4TestAdapter(InvalidMethodTest.class);
adapter.run(result);
assertEquals(1, result.errorCount());
TestFailure failure = result.errors().nextElement();
assertTrue(failure.exceptionMessage().contains("Method shouldBeStatic() should be static"));
}
use of junit.framework.TestResult in project junit4 by junit-team.
the class ForwardCompatibilityTest method testNotifyResult.
public void testNotifyResult() {
JUnit4TestAdapter adapter = new JUnit4TestAdapter(ErrorTest.class);
TestResult result = new TestResult();
final StringBuffer log = new StringBuffer();
result.addListener(new TestListener() {
public void startTest(junit.framework.Test test) {
log.append(" start ").append(test);
}
public void endTest(junit.framework.Test test) {
log.append(" end ").append(test);
}
public void addFailure(junit.framework.Test test, AssertionFailedError t) {
log.append(" failure ").append(test);
}
public void addError(junit.framework.Test test, Throwable e) {
log.append(" error " + test);
}
});
adapter.run(result);
String testName = String.format("error(%s)", ErrorTest.class.getName());
assertEquals(String.format(" start %s error %s end %s", testName, testName, testName), log.toString());
}
use of junit.framework.TestResult in project junit4 by junit-team.
the class ForwardCompatibilityTest method testExpected.
public void testExpected() {
TestResult result = new TestResult();
junit.framework.Test adapter = new JUnit4TestAdapter(ExpectedTest.class);
adapter.run(result);
assertTrue(result.wasSuccessful());
}
Aggregations