Test Cases: Learn how to Write Effective Ones
In order to verify that your software works as intended, you’ll obviously need to test it. In order to properly test a specific function or feature, test cases contain a list of actions. For many types of testing, whether it’s manual regression or automation, you need that set of instructions. To create a good test case, there are a few different approaches you might take, but there are certain standards that are worth considering.
Today, we’re going to look at a few tips to help you write good, effective test cases.
Make it simple and clear.
Starting with the naming convention, which should make it easy to understand what the test case is intended to test, you should take your time and ensure that every aspect of the test case is easy to understand. It might need to be followed by a new tester, or form the basis of an automated script later down the line, so clarity is vital. Break everything down into simple, chronological steps so that someone with no knowledge of the project could run the test case.
Consider the end user.
You might be working from a requirements document, a user story or the application itself. In each case, you need to keep the end user at the forefront of your mind. How would they expect the software to work? What are they looking for from the function? How would they go about their task? Does it meet expectations?
Think about prerequisites.
Every aspect of the environment and the setup is important. Consider the tools to use, the operating system, the hardware, the data and the flow. You want to model the end user’s behavior, and the final live environment that they’ll be using the software in, as closely as possible. In some cases, creating relevant test data will require a whole procedure in itself. Rather than referring to specific test data that might age, list criteria for creating relevant test data. You may also want to list other test cases as prerequisites.
Explain the expected result.
Ideally, every step of your test case will have an expected result attached. This makes it easy to verify each step and ensure coverage is complete. It should be clear to anyone working through this test case later what is supposed to happen at every step.
Add supporting material.
To help the tester understand exactly what they’re supposed to do and what the expected outcomes are, screenshots, additional explanations and videos are useful supplements. In many cases, it might be best to use a capture tool of some kind while you test. Recording keystrokes and environment details, or even entire exploratory test sessions, and breaking out relevant parts to use as the basis for test cases is a good way to make sure you aren’t forgetting anything.
Think about the future.
To get maximum value out of taking the time to write up a test case, it should be reusable. It’s important to take the time to avoid duplicating work. Test cases should call other test cases as prerequisites rather than cover the same ground. Sometimes you’ll be able to reuse test cases from one project to another. And for any test cases that need to be updated or retired, schedule in some review and maintenance time.
The specifics of writing good, thorough test cases may vary from project to project, but these principles are always worth keeping in mind.
ABOUT THE AUTHOR:
Simon is an experienced freelance technology journalist covering mobile technology, software, and videogames for a wide variety of clients in print and online. He regularly contributes to Digital Trends, Tech Radar, and Android Authority, and he ghostwrites for CEOs in the technology space. After completing a Masters in Scottish History at Edinburgh University, he began his career as a games tester, progressing to lead tester, game designer, and finally producer, before leaving the industry to write full time. He is passionate about the potential for good software and hardware to improve our lives, and strongly believes that thorough testing is a vital prerequisite for greatness.