When we have failing tests, it is important to immediately know what went wrong and under which circumstances. This will allow you to tackle the problem quicker before deciphering an ambiguous test.

A good naming convention is the {WHAT} Should {doX} When {circumstances}, for example Add/2 Should return the sum When parameters are integers and Add/2 should throw error When a parameter is not an integer.

Controller endpoint tests

When we do endpoint tests we can even make it a bit more strict and straightforward with the VERB route Should STATUSCODE STATUS When {circumstances}.

For example GET /practice/history Should 200 OK when no query parameters are given and GET /practice/history Should 422 UNPROCESSABLE ENTITY when count query parameter is not an integer.