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.

I would pick a similar name strategy as your team uses for their unit-tests, something like: UnitOfWork_StateUnderTest_ExpectedBehavior for more ideas look here: https://stackoverflow.com/questions/155436/unit-test-naming-best-practices


As if for any function, your test should explain what it does.

withdraw_is_performed_correctly | withdraw_is_not_performed_when_balance_is_not_enough

user_is_able_to_logout | user_is_not_able_to_logout_if_he_is_not_logged



Intention Revealing: As with any other test names,happy path tests name should be intention revealing about what functionality it covers.

Think in case of multiple happy path scenarios for same functionality, how by names you can differentiate and reveal the unique 'user journey'(code path) to the reader.

Many times by uniquely naming the tests itself ,we discover test steps redundency.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.