I'm learning to use JUnit.
Some of my tests have come up as "errors" and some as "failures". What's the difference between the two?
An error is when something breaks and an exception occurs, such as a Null object reference.
A failure is when the test criteria is not met. i.e. when the Assert()
fails.
[This is in general, not just junit.]
In simple words,
Errors - mean that while your test was running, there were some unhandled/unforeseen exceptions, and hence, your test case basically crashed without executing fully.
Failures - mean that your test completed successfully, but the test condition of your test criteria has failed(not what you expected it to be).
A failure is when one of your assertions fails--that is, your program does something wrong, and your JUnit test notices and reports the fact.
An error is when some other Exception occurs--one you haven't tested for and didn't expect, such as a NullPointerException or an ArrayIndexOutOfBoundsException.
Failure - When test case fails (Condition that you assert did not succeed)
Error - Unexpected scenarios or errors in executing the test case
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With