Bad Test Case vs Good Test Case
Example of Google Test Case
Test Cases are an important part of testing. There's a right way and a wrong way to write a test case. Do it the wrong way and you risk the value of the test case.
Here's an example of the Wrong Way / Right Way situation.
Bad Test Case
Test Case Name: Check that Google.com works
Steps:
- Go to Google.com
- Type something in the search bar
- Press Enter
Expected Result: Google returns some search results
This test case is bad for the following reasons:
- It is too vague. It does not specify what to type in the search bar, or how to verify that Google returned some search results.
- It does not test any negative cases. For example, what happens if the user types in an invalid search query? What happens if the user's internet connection is down?
- It is not comprehensive. It does not test all of the possible ways that Google.com could be used. For example, what happens if the user clicks on one of the search results? What happens if the user clicks on the "Settings" button?
Good Test Case
Test Case Name: Verify that Google.com returns relevant search results for a valid search query
Steps:
- Go to Google.com
- Type "cats" in the search bar
- Press Enter
- Verify that the top 10 search results are all relevant to the search query "cats"
Expected Result: The top 10 search results are all relevant to the search query "cats"
This test case is better because it is more comprehensive. It tests a scenario that is more likely to occur in real life (a user wanting to find relevant search results), and it includes a step to verify the expected result for that scenario.