Stay clear, stay focused: writing test cases

By: Slav Kurochkin

Before you start writing test case try to understand key of the feature, who and why need it, how critical impact would be if it's not delivered on time or brakes.

For example we are working on software where all events can be performed after user logedin. So if login is not working it will make critical impact on software usability.

Title: What is the goal?

Title is one of the key components for the test case, try to write title clear and understandable for test and development engineer so anybody who read it would be able to get the point of test case without even reading whole test case. For example it would be clear enough and developer wouldn't waste time on deep understanding. Unfortunately it is not always possible, but try to do it as much focused and clear as you can.

Test Body: What should I do to achieve feature goal?

Body is the main element of test case and simply tell tester steps how to achieve certain goal we set in a title.

Sometimes you can see that test body contains multiple tests. For example while testing login functionality qa folks testing something else on login page. So instead focusing on particular feature engineer focusing on the speed and most of the time it's just creating mess.

Lets talk about login example, the title of the test saying "User able to login into the system", poorly written test case would try to cover everything on login page, even though it have nothing to do with login functionality, such as reset password or signup. Here is an example I have seen a lot:

1. User open login page
2. User click on forget password url and back to login page
3. User click on signup page and back to login page
4. User type username and password
5. Hit login and assert certain page presented

Steps 2 and 3 in test case have nothing to do with login functionality, from code prospective they should not interferer anyhow with login. If we look at test case above from test automation prospective, we can see when signup url brakes your entire test case fail and will be presented as failed test case with title "User able to login into the system". Here is question I would ask you, is it true that user can't login? Obviously not, then we are misleading Dev and QA team, just because we got lazy to write separate test cases.

Expected result: How can I be sure goal have been achieved?

Having goal set does not always mean it is been achieved, when you writing expected result, make sure it is matching test case title. I have seen sometimes people trying to test one functionality and the end they taking different path and achieving something what was not intend to achieve. The good practice is assertion or validation, basically comparing expected with actual result.

Conclusion:
1. Before starting write test case make sure you understand feature, who and why need that feature.
2. Make sure your title is clear enough and your teammates will get the point of test cases without even reading whole thing.
3. Stay focused one feature per test cases, don't try to test multiple things in one test case
4. Always make sure the goal which been set in the title have been achieved after performing all the steps in test case.

View Comments

Leave a Comment

Use markdown or basic HTML and be nice.