use of junit.framework.TestCase in project junit4 by junit-team.
the class TestListenerTest method testError.
public void testError() {
TestCase test = new TestCase("noop") {
@Override
public void runTest() {
throw new Error();
}
};
test.run(fResult);
assertEquals(1, fErrorCount);
assertEquals(1, fEndCount);
}
use of junit.framework.TestCase in project junit4 by junit-team.
the class TestCaseTest method testSetupFails.
public void testSetupFails() {
TestCase fails = new TestCase("success") {
@Override
protected void setUp() {
throw new Error();
}
@Override
protected void runTest() {
}
};
verifyError(fails);
}
use of junit.framework.TestCase 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.TestCase in project junit4 by junit-team.
the class OldTestClassAdaptingListenerTest method addFailureDelegatesToNotifier.
@Test
public void addFailureDelegatesToNotifier() {
Result result = new Result();
RunListener listener = result.createListener();
RunNotifier notifier = new RunNotifier();
notifier.addFirstListener(listener);
TestCase testCase = new TestCase() {
};
TestListener adaptingListener = new JUnit38ClassRunner(testCase).createAdaptingListener(notifier);
adaptingListener.addFailure(testCase, new AssertionFailedError());
assertEquals(1, result.getFailureCount());
}
use of junit.framework.TestCase in project android-junit-report by jsankey.
the class JUnitReportListener method startTest.
@Override
public void startTest(Test test) {
try {
if (test instanceof TestCase) {
TestCase testCase = (TestCase) test;
checkForNewSuite(testCase);
mSerializer.startTag("", TAG_CASE);
mSerializer.attribute("", ATTRIBUTE_CLASS, mCurrentSuite);
mSerializer.attribute("", ATTRIBUTE_NAME, testCase.getName());
mTimeAlreadyWritten = false;
mTestStartTime = System.currentTimeMillis();
}
} catch (IOException e) {
Log.e(LOG_TAG, safeMessage(e));
}
}
Aggregations