A test case consists of two parts
- Action
- Result
Test cases should then be named accordingly. For an action, it should produce a result. The action word should be modified as per the context.
def test_action_produces_result
In the above name, the produces is the action word.
Check these names (Replace model with your specific table name)
def test_form_saves_title_field_in_model
def test_post_redirects_to_home_page
def test_recalculate_updates_score_field_in_model
Corner cases can be tricky. You might be tempted to write otherwise. For ex:
def test_score_field_is_present_in_excel
In this case the action gets missed. However, the formula of action_produces_result can be always applied to provide more context
def test_exported_excel_has_score_field
There are some cases where you aren't bothered about the result. These are usually in cases of regression. For ex:
def test_users()
However too many test cases of this type are mostly a result of laziness and should be cleaned up.
Top comments (0)