What’s the difference between failure and error in JUnit?

By | June 30, 2019

Question

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?

Solution

Ok, I’ve just noticed a pattern and think I’ve figured it out (correct me if I’m wrong). It seems to me that failures are when your test cases fail – i.e. your assertions are incorrect. Errors are unexpected errors that occur while trying to actually run the test – exceptions, etc.

Rate this post

Leave a Reply

Your email address will not be published. Required fields are marked *