Eight Tips to Writing Simple Test Cases
Take a structured approach when writing test cases. Just a few best practices, when followed, ensure you write good test cases. It is simple just make sure to:
1. Identify the purpose of testing
2. Define how to perform testing
3. Identify Non-functional requirements
4. Define a framework of test cases
5. Become familiar with the modular principle
Structuring of Test cases
Now you have all the required information to begin writing test cases. We will talk about the structure of a test case. Requirements of the software are mapped with test scenarios, which are further elaborated in test cases. For each test scenario, we define test cases. In each test case, we define Test Steps. Test Step is the smallest entity under any test case. It specifies the action to be performed and expected result of the test application.
Typical flow for test cases:
1. Test Case ID
2. Module to be tested
3. Test Data
4. Test Steps
5. Expected results
6. Actual results
While conducting tests mark your results against each step, such that the defect report provides respective test case ID that failed during execution.
The length of test cases varies depending on the tester, some write detailed ones while other keep it simple and short. However, it is recommended to keep them short.
Tips to Write Effective Test Cases
- Self-explanatory and specific – Test cases should have sufficient details so that new testers can execute them without any help. All the pre-requisite for executing tests should be mentioned in the tests itself. Test cases should also clearly specify the purpose and scope of the procedure.
- Valid and concise – Test cases should optimal steps, enough to fulfill test parameters.
- Traceable – Test cases should cover all software requirements, and every test case should be mapped against the “Requirement ID”. This practice also helps during impact analysis.
- Maintainable – With changes in requirement, testers should maintain the suite of test cases. It should reflect the changes in software and accordingly steps should be modified.
- Positive and negative coverage – Test cases should test for boundary values, equivalence classes, normal, and abnormal conditions. Apart from testing for expected results, the negative coverage can help in testing failure conditions and error-handling.
- Coverage for Usability aspect – The UI interface should be tested for ease of use. The overall layout and color should be tested against a style guide, if defined and against the signed off mock- up designs.
- Test Data – There should be diversity in data to be used in test cases such as - Valid data, Legitimate invalid data (to test boundary value), Illegal, and abnormal data (to test error handling and recovery).
- Non-Functional aspect – The test cases should cover scenarios for basic performance testing, security aspects, browser support, etc.
Structure your tests to cover all the functional requirements first, and then include test cases for non-functional requirements, as they are equally important for proper functioning of the software.