Are you new to testing? We are delighted that you’ve started to learn about testing.
What is a Test Case?
Test Cases are a set of preconditions, inputs, actions (where applicable), expected results, and postconditions developed based on test conditions.
A Test case is an executable test case with the instructions a tester needs to perform.
It will have step-by-step instructions to verify the behavior of the action as it behaves like the expected one in the requirements.
Components of Test Case
In general, a Test case consists of the below components:
- Test Case ID
- Test Case Title
- Description of the test case
- Precondition
- Test Steps
- Expected Result
Test Case ID
This is a unique identifier of the test case in the product/project.
Test Case Title
A great test case should have a strong title. The title should have crisp information about what you are going to test.
Description of the Test Case
The description of what requirement is being tested in 2 to 3 lines. It should be easier to understand what the test case is trying to accomplish at the high level.
Preconditions
This includes any pre-requisite before moving towards the steps to test.
Test Steps
Test Steps are a sequence of steps needed to be followed to complete the test case execution.
Expected Result
The output of the test steps is defined as the expected result.
Best Practices to Write Test Cases
When the test cases are well written, then the execution will be seamless. When you go through the requirements, you have to think from the end user’s perspective to write the test cases.
Sharing a few best practices in writing the test cases:
- The test case title should be short.
- Keep your description as comprehensive.
- Be clear & concise.
- Include both the positive and negative test cases.
- Align the expected result with the requirements.
- Make your test cases reusable.
- Get peer-reviewed.
Next, we are going to see a sample simple test case to understand it better. The test scenario is subscribing to a blog simply. The form will look like this:
Test Case ID | Test Case Title | Description | Preconditions | Test Steps | Expected Result |
TC0001 | Verify with the valid email address | Verify the blog subscription functionality with a valid email address. | 1. Enter the valid email address.
2. Click Subscribe. |
The email id should be subscribed to the mailing list. | |
TC0002 | Verify with the invalid email address | Verify the blog subscription functionality with the invalid email address. | 1. Enter the invalid email address.
2. Click Subscribe. |
The system should show the alert message as “Enter a valid email address.” | |
TC0003 | Verify with the already subscribed email id. | Verify the blog subscription functionality with the already subscribed mail id. | The input mail id should be subscribed earlier. | 1. Enter the email id john@test.com.
2. Click Subscribe. 3. Again, enter the same mail id john@test.com. 4. Click Subscribe. |
The system should show the alert message as The email id “john@test.com” is already subscribed. |
TC0004 | Verify without entering any values | Verify the blog subscription functionality without entering any value. | 1. Without entering any values.
2. Click Subscribe |
The system should show the alert message as “Enter a valid email address.” | |
TC0005 | Verify with the special characters | Verify the blog subscription functionality with the various special characters. | 1. Enter the values with the special characters.
2. Click Subscribe. |
The system should show the alert message as “Enter a valid email address.” |
Benefits of Writing Test Cases
You may wonder why I should write the test cases and what are the benefits of that. The benefits of writing test cases are:
- To ensure test coverage.
- To improve the software.
- To confirm the application matches the requirements.
- To identify the gaps in the requirements.
- To identify the usability issues.
Writing compelling test cases needs a little practice, and the knowledge of the application is being tested. Great documentation of the test cases plays a vital role in the testing process and save your time in the long run. By using QA Touch, you can manage and organize your test cases effectively.