We have a rather reach set of unit tests for our Python/Django backend. Most of the tests contain a one or more "happy" path tests and a lot of "negative" test cases checking the validation, error-handling, broken pre-conditions etc.

When, most frequently, a test contains a single happy path test though, it is currently just simply a test named test_ok (Python unittest method name):

def test_ok(self):
# happy path test here

My understanding is that there are certainly better ways to name positive test cases.

What are some of the best practices and things to take into account to name positive tests?

3 Answers
3

If there is one thing I like about good test names is that when it fails on a build-server I can understand what is broken just from reading its name. If the name of the test does not describe what it does it means you need to read the test code to see what is going on.

When an automated test fails, I want to understand what I just broke — without
reading the test code.

Good names are also very helpful for non technical people, certainly if they need to decide on priority of fixing. E.g. do we need to fix this today or can we wait until tomorrow morning when the developers are already out of the zone.