Good practices for writing test cases
Posted: Tue Jan 21, 2025 4:28 am
Let's face it: Writing test cases is an art. A good test case will throw up issues and defects that weren't even envisioned in the requirements. For example, what if the name field had two spaces? Or if the user's last name had a hyphen?
To ensure that your test cases are geared towards delivering high-quality software, consider the following best practices.
Think like a user
Before writing your test cases, think from a user's perspective. Be critical and granular. In the example we've discussed so far, you might ask:
What does "name" mean? First name? Last name? Or both?
Whose name is this? Should the field name text say "your name"?
Should there be text to guide the reader?
If the user enters an invalid name, should the error message identify what is wrong?
Put yourself in the user's shoes. Explore various possibilities and even edge cases. You may not vp business development email list create test cases for all of them, but exploring them helps to reinforce the feature.
Focus on one thing at a time
Don't write a functional test case that is also a usability test case and a database test case. Keep it one thing at a time. That way, when a test result is successful or unsuccessful, you'll know exactly what worked or what failed.
Including too many variables in a test will compound problems when the test fails.
Don't do it alone
Test cases define the quality of the software. Even though you are the tester in the doer-verifier process, you need another layer of review from two people. So, once you have written the test cases, get it peer reviewed.
Ask a colleague to review what you have written. Encourage them to find flaws and give you critical feedback. Also check with business analysts and developers to better understand their intent.
To ensure that your test cases are geared towards delivering high-quality software, consider the following best practices.
Think like a user
Before writing your test cases, think from a user's perspective. Be critical and granular. In the example we've discussed so far, you might ask:
What does "name" mean? First name? Last name? Or both?
Whose name is this? Should the field name text say "your name"?
Should there be text to guide the reader?
If the user enters an invalid name, should the error message identify what is wrong?
Put yourself in the user's shoes. Explore various possibilities and even edge cases. You may not vp business development email list create test cases for all of them, but exploring them helps to reinforce the feature.
Focus on one thing at a time
Don't write a functional test case that is also a usability test case and a database test case. Keep it one thing at a time. That way, when a test result is successful or unsuccessful, you'll know exactly what worked or what failed.
Including too many variables in a test will compound problems when the test fails.
Don't do it alone
Test cases define the quality of the software. Even though you are the tester in the doer-verifier process, you need another layer of review from two people. So, once you have written the test cases, get it peer reviewed.
Ask a colleague to review what you have written. Encourage them to find flaws and give you critical feedback. Also check with business analysts and developers to better understand their intent.