I\'m running JUnit tests on a large code base, and I\'ve been realizing that sometimes I get \"Errors\" while other times I get \"Failures\". What\'s the difference?
I have commented the line which throws test error and test failure.
@Test
public void testErrorVsTestFailure() {
final String sampleString = null;
assertEquals('j', sampleString.charAt(0) );
//above line throws test error as you are trying to access charAt() method on null reference
assertEquals(sampleString, "jacob");
//above line throws Test failure as the actual value-a null , is not equal to expected value-string "jacob"
}
So Junit shows test error whenever you get an exception , and test failure when your expected result value doesn't match your actual value