When the org.junit.runner.notification.Failure's object getException() method return value is != null, is that equivalent to an Error (as opposed to a Failure) in Eclipse's JUnit view?
I have a JUnit4 test
public class NewTests
{
@Test
public void SampleTestPass()
{
org.junit.Assert.assertTrue(true);
}
@Test
public void SampleTestFail()
{
org.junit.Assert.assertTrue(false);
}
@Test
public void SampleTestError()
{
throw new Exception();
}
}
which I bundle into a suite with
import org.junit.runners.Suite;
import org.junit.runner.RunWith;
@RunWith(Suite.class)
@Suite.SuiteClasses({NewTests.class})
public class SampleTestSuite {
}
this is executed by:
Result result = JUnitCore.runClasses(SampleTestSuite.class);
if(result.wasSuccessful())
{
output = "passed";
}
else if(result.getFailureCount != 0)
{
output = "failed";
}
how do I distinguish the third case where the test results in an error?
When I run the JUnit tests from Eclipse I am presented with a pass for the first test, a failure for the second test and an error for the third test.
When using JUnit3 and running my tests with
TestSuite suite = new TestSuite(NewTests.class);
TestResult result = new TestResult();
suite.run(result);
I could use the junit.framework.TestResult class and call failureCount() and errorCount() to get all the information I needed.
The only similar thing I could find was that inside the JUnit4 result object there is a org.junit.runner.notification.Failure object that can contain the thrown exception returned from getException() which returns a throwable. If this is populated is this the equivalent to the JUnit3 result.errorCount and so can I assume that the thrid (error) case is satisfied iff there is a throwable returned from org.junit.runner.notification.Failure.getException()?