Writing effective test cases is crucial for ensuring the quality and reliability of software applications. So, in this comprehensive guide from Tekos Interactive, we’ll walk you through the essential steps and best practices to create test cases that meet industry standards and maximize test coverage.
What is a test case?
A Test Case is a set of steps to verify a particular feature or function of the software application. Specifically, a Test Case contains test steps, test data, preconditions, and post-conditions developed for specific test scenarios to verify any given requirement. Furthermore, the test case includes specific variables or conditions, which a testing engineer uses to compare expected and actual results. This comparison is crucial because it determines whether a software product is functioning as per the customer’s requirements.
The format of standard test cases
Below is a standard login test case example format.
Test Case ID | Test Case Description | Pre-Condition | Test Steps | Expected Results | Actual Result |
LI01 | The account can not be logged in | UserId: “test@gmail.com” and Password:”123456” existed on the system | 1. Go to site https://accounts.google.com/ 2. Enter UserId “test@gmail.com” 3. Click “Next” button 4. Enter Password ”123456” 5. Click “Next” button | The account can be logged in | Pass |
LI02 | Check behavior when the user login with valid Data | Check Customer login with invalid Data | 1. Go to site https://accounts.google.com/ 2. Enter UserId “test123@gmail.com” 3. Click “Next” button 4. Enter Password ”123456” 5. Click “Next” button | Account can not be logged in | Pass |
This is a general format, and you can adapt it to suit your project and team’s specific needs. Therefore, it’s important to maintain consistency across test cases within a project to ensure clear communication and easier test management. You can use the explanations given below to avoid confusion while writing a test case.
Test Case ID: A unique identifier for the test case, often generated using a numbering system.
Test Case Description: A summary of what the test case aims to validate or the functionality it tests.
Test Steps: A detailed list of step-by-step instructions to execute the test case. Each step should be clear, concise, and specific.
Test Data: The specific data inputs or conditions required to execute the test case. This may include sample values, preconditions, or dependencies.
Expected Result: The expected outcome or behavior when executing the test case. It should be specific and written in a passive voice.
Actual Result: The actual outcome observed when executing the test case. Testers fill in this field during the test execution phase.
Test Environment: Testers execute the test case in this specific environment or configuration. This may include details such as hardware, software, browsers, operating systems, or any other relevant information.
Test Data Setup: Any specific data setup or configuration required before executing the test case. This is particularly important when dealing with complex test scenarios or dependencies.
Test Execution Date: The date when the test case was executed.
Test Case Status: The overall status of the test case, which may include categories like “Not Tested”, and “Pending”.
Pass/Fail: It should be marked as either ‘Pass’ if the actual result matches the expected result, or ‘Fail’ if the actual result does not match the expected result.
Comments/Notes: Any additional notes, comments, or observations related to the test case execution or results.
How to write effective test cases
Writing effective test cases is crucial for achieving comprehensive test coverage and ensuring the delivery of high-quality software. Adhering to standardized practices and guidelines, such as those outlined by the International Software Testing Qualifications Board (ISTQB), can help minimize confusion and gaps in test coverage. In this guide, I will provide you with a step-by-step approach to writing effective test cases, following the ISTQB standards.
Define the scope and module
Before writing test cases, create a high-level checklist or use a set of the most important requirements to define the scope of work and identify the main modules or elements that need to be verified. Therefore, divide them into logical parts to easily group test cases into test scenarios.
Best Practice
Label or tag each test case with the corresponding module/component for easy identification.
Prioritize test cases based on their criticality.
Apply test design techniques
Utilize recognized test design techniques to save time, provide comprehensive coverage, and test your application in a structured and systematic manner, following the ISTQB Glossary:
a. Equivalence Partitioning: Design test cases that cover representatives from each equivalence partition, ensuring that each partition is tested at least once.
b. Boundary Value Analysis: Design test cases based on boundary values, covering both valid and invalid boundaries within partitions.
c. Decision Table Testing: Design test cases to exercise combinations of conditions and resulting actions as specified in a decision table.
d. Use Case Testing: Design test cases to validate use case behaviors, ensuring end-to-end testing of the system using realistic business user scenarios.
e. State Transition Testing: Design test cases to exercise elements of a state transition model, particularly useful when the system has a finite number of states.
Best Practice:
Analyze your software model and select one or more of these test design techniques to create effective test cases.
Use requirements traceability matrix (RTM)
Create a Requirements Traceability Matrix (RTM) to visualize the relationship between requirements and test cases, ensuring comprehensive coverage and identifying any gaps or areas with excess or insufficient testing. That is to say, the RTM maps and traces user requirements with corresponding test cases.
Best Practice:
Fill the RTM not only with direct links to specification items and test cases but also record specific and critical bugs found during testing.
Make test cases complex but simple
Ensure that each test case contains all the necessary details, relevant artifacts, and graphical user interfaces (GUIs). Meanwhile, test cases should be grouped into logical test suites, with each step being atomic and in the correct sequence. Moreover, include relevant test data that the specific input values are being tested.
Best Practice
Adopt a standardized test case template across the project to maintain consistency.
Review all test cases from a tester’s perspective to ensure clarity and appropriate expected results.
Review your own and your teammates’ test cases
Conduct thorough reviews of your own test cases and those written by your teammates. This helps identify any uncertainties, mistakes, or gaps before test execution.
Best Practice
Review Test Cases written by another tester. This will help you identify uncertainty, mistakes or gaps before testing.
Keep test cases up to date
Test cases should be regularly reviewed and updated to reflect changing requirements, new ideas, and additional test scenarios that arise during execution. Therefore, ensure test case documentation remains relevant and effective throughout the project.
Best Practice
Link test cases to bugs and build new test cases if the issue you find is not already covered by a test case.
Provide examples and test data
Give a range of inputs as examples or attach relevant documents, fields, or calculations to test data. This ensures that crucial test data is not missed during the test execution.
Distribution of test cases
a. Assign Testers: Assign multiple testers to different modules of the application based on their areas of expertise. To clarify, this ensures a focused approach to testing and encourages in-depth knowledge of specific modules.
b. Test Case Allocation: Divide test cases among testers according to the designated areas of the application that require testing. Consequently, this facilitates comprehensive coverage of the application and efficient utilization of resources.
Rotation of test cases execution
Implement a rotation mechanism for test case execution among testers. This practice ensures that various perspectives and insights are incorporated into the testing, thereby improving the overall effectiveness of the process.
Best Practice:
Rotate test case execution for different areas between testers to promote a broader understanding of the application and encourage new scenarios.
Don’t forget about your checklist
Remember that Test Cases are not the only test documentation used for manual testing. Therefore, analyze the size and business logic of the application, duration of the project, team size, and customer expectations. For short-term projects with clear and simple logic when we lack Quality Assurance resources and time, or when the logic of the application changes too often, it’s more time-efficient to use checklists instead of test cases. One of the good practices is to have a checklist for specific verification that we run not so often, but it is important to have it as a list of checks.
Best Practice:
Use a checklist for smoke/sanity tests on big projects with complex logic even if detailed test cases exist. It helps to concentrate on the most important scenarios.
Would you like to read more articles by Tekos’ Team? Everything’s here.
References
– Write Test Cases with Examples
– How to Nail Your Test Cases Every Single Time
– How to Write Test Cases: A Step-by-Step QA Guide