Introducing Fest

Another weapon for our testing arsenal is better testing assertions. Have you noticed how sometimes stacktraces for failed tests are really unfriendly and/or mystically wrong? They give you little information about the real failure and you end up confused, having to read the entire source to fathom out how to fix the problem.

As an example, look at this assertion:

org.junit.Assert.assertEquals(3, myList.size());

We are asserting that a collection of objects after some task has a size of three, look at our error message when the test fails:

java.lang.AssertionError: 
Expected :3
Actual   :2

Ok, that kind of makes sense, but it's a bit abstract. What item is missing from our list? I am going to have to run the tests again to find out, or ...

Get Learning Android Application Testing now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.