What is a Test Case?
A test case template is a document that comes under one of the test artifacts, which allows testers to develop the test cases for a particular test scenario in order to verify whether the features of an application are working as intended or not. Test cases are the set of positive and negative executable steps of a test scenario which has a set of pre-conditions, test data, expected results, post-conditions, and actual results.
Most of the companies are using test case management tools such as Quality Center (HP QC), JIRA, etc., and some of the companies still using excel sheets to write test cases.
Check the below video to watch “How To Write Test Cases Manually”
What is the difference between Test Scenario vs Test Case?
Test Scenario: Test Scenario gives the idea of what we have to test. Test Scenario is like a high-level test case.
For example: Verify the login functionality of the Gmail account.
Also read Test Scenario vs Test Case
Assume we need to write test cases for a scenario (Verify the login of the Gmail account).
Here are some test cases.
1. Enter valid User Name and valid Password
2. Enter valid User Name and invalid Password
3. Enter invalid User Name and valid Password
4. Enter invalid User Name and invalid Password
Who Writes Test Cases?
It varies from company to company. Assuming that a team contains developers and dedicated testers then it might be something like a joint effort.
- Developers write Unit Tests
- Developers & Testers write Integration Tests
- Testers write Acceptance Tests
General Test Case Template Format
Find the test case template screenshot below:
How To Write Test Cases in Manual Testing
Follow the below steps to write the test cases.
Step 1 – Test Case ID:
Each test case should be represented by a unique ID. It’s good practice to follow some naming convention for better understanding and discrimination purposes.
Step 2 – Test Case Description:
Pick test cases properly from the test scenarios
Test scenario: Verify the login of Gmail
Test case: Enter a valid username and valid password
Step 3 – Pre-Conditions:
Conditions that need to meet before executing the test case. Mention if any preconditions are available.
Example: Need a valid Gmail account to do login
Step 4 – Test Steps:
To execute test cases, you need to perform some actions. So write proper test steps. Mention all the test steps in detail and in the order how it could be executed from the end-user’s perspective.
- Enter Username
- Enter Password
- Click Login button
Step 5 – Test Data:
You need proper test data to execute the test steps. So gather appropriate test data. The data which could be used an input for the test cases.
- Username: firstname.lastname@example.org
- Password: STM
Step 6 – Expected Result:
The result which we expect once the test cases were executed. It might be anything such as Home Page, Relevant screen, Error message, etc.,
Example: Successful login
Step 7 – Post Condition:
Conditions that need to achieve when the test case was successfully executed.
Example: Gmail inbox is shown
Step 8 – Actual Result:
The result which system shows once the test case was executed. Capture the result after the execution. Based on this result and the expected result, we set the status of the test case.
Example: Redirected to Gmail inbox
Step 9 – Status:
Finally set the status as Pass or Fail based on the expected result against the actual result. If the actual and expected results are the same, mention it as Passed. Else make it as Failed. If a test fails, it has to go through the bug life cycle to be fixed.
Other important fields of a test case template:
Project Name: Name of the project the test cases belong to
Module Name: Name of the module the test cases belong to
Reference Document: Mention the path of the reference documents (if any such as Requirement Document, Test Plan, Test Scenarios, etc.,)
Created By: Name of the Tester who created the test cases
Date of Creation: When the test cases were created
Reviewed By: Name of the Tester who created the test cases
Date of Review: When the test cases were reviewed
Executed By: Name of the Tester who executed the test case
Date of Execution: When the test case was executed
Comments: Include value information which helps the team
Best Practices To Write Good Test Case
A well-written test case should:
- Easy to understand and execute
- Create Test Cases with End User’s perspective
- Use unique test case id
- Have a clear description
- Add proper pre & postconditions
- Specify the exact expected result
- Test cases should be reusable & maintainable
- Utilize testing techniques
- Get peer review
If you follow the best practices to write test cases then anyone in the team can understand and execute the well-written test case easily. It should be easy to read and understand, not only for whoever wrote it but also for other testers as well.
Easy to understand and execute:
To make the test cases easy to understand and execute faster we need to use simple and easy to understand language like “Go to login page”, “enter username”, “enter password”, “click on login button” and so on.
Create Test Cases with End User’s perspective:
Create test cases by keeping end-user in mind. The test cases you create must meet customer requirements.
Use unique Test Case ID:
It’s good practice to follow a unique id with some naming convention for better understanding and discrimination purposes.
Have a clear description:
Your test case description should be clear enough to understand what the tester is going to do with this test case.
Add proper preconditions & postconditions:
In some cases, test cases need to meet some conditions before execution or achieve some conditions after execution. These conditions we need to mention properly in the Pre and postconditions.
Specify the exact expected result:
Include the Expected result: Expected result tells us what will be the result of a particular test step. Testers decide the pass or fail criteria based on the expected result.
Test cases should be reusable & maintainable:
A well written test case is reusable and maintainable. There ar times where developers change the code, and testers need to update the test cases. If our test cases are easy to read and understand then it would be easy to update them not only by whoever wrote it but also by other testers as well.
Utilize testing techniques:
Use testing techniques whenever necessary. Software test design techniques are used to derive the test cases from the Requirement Specification document and also based on testers expertise
- Equivalence Partitioning
- Boundary Value Analysis
- Decision Table
- State Transition
- Exploratory Testing
- Error Guessing
Get peer review:
Let your peers review your test cases to uncover the defects in your test case design.
Popular Test Case Management Tools
some of the popular tools for the test management process are
- Test Rail
- Test Collab
- Meliora Testlab
Don’t miss this detailed article on Best Test Case Management Tools in the market.
Download Test Case Template
A sample Test Case – Template for your reference.