What is a Test Case and How to Write Test Cases?
This hands-on article on What is a Test Case and How to Write Test Cases covers the details of a Test Case, its definition, levels of test case writing process, and why do we write test cases.
What is a Test case?
A set of preconditions, inputs, actions (where applicable), expected results, and post-conditions developed based on test conditions.
Writing good test cases is a skill. You can learn it from the experience and knowledge of the application under test.
Levels of Test Case writing process:
1. First Level: In this level, you will write the fundamental test cases from the available specification and user documentation.
2. Second Level: This is the practical stage, in which you will write test cases that depend on the actual functionality and system flow of the application.
3. Third Level: In this level, you will combine test cases to write a test procedure. The test procedure is nothing but a group of small test cases.
4. Fourth Level: Automation of the project (if required). It will minimize human interaction with the system. Therefore, the tester can focus on the currently updated functionalities to test rather than remain busy with Regression testing.
Why do we write Test Cases?
The main goal of writing cases is to validate the test coverage of an application.
If you work in any CMMI-level organization, these organizations strictly follow test standards. Writing cases brings some standardization and minimizes the ad hoc approach in testing.
How to Write Test Cases?
Writing test cases differs depending on what the test case is determining or testing. And it all starts with knowing how to write a test case effectually and competently. A test case has a few significant parts that should always be present in fields. But, every test case can be broken down into the following basic steps:
· Test case ID: Test cases should have unique IDs to represent them.
· Test Case Description: The test case description should reveal what area, item, feature, or function is being tested or what is being verified.
· Priority: The importance of the test case to the application.
· Assumptions & Pre-conditions: This involves any conditions to be met before test case execution. One example would be requiring a valid Email account for login. The actions of the user or the system must have occurred for the functionality to be provided. Preconditions do not include steps in the Test Case Workflow.
· Test data: It is related to the variables and their values in the test case. For example in the case of Email login, it would be the username and password for the account.
· Steps to be executed: These are easily repeatable steps as executed from the end user’s perspective. For example, a test case for logging into an email server might include the following steps:
Open email server web page.
Provide username.
Provide password.
Click the “Enter” or “Login” button.
· Expected Result: It shows the result expected after the test case step execution. Upon entering the right login information, the expected result would be a successful login.
· Actual result & Post-conditions: As compared to the expected result, we can determine the status of the test case in the actual result. In the case of the email login, the user would either be successfully logged in or not. The post-condition is what happens as a result of the step execution such as being redirected to the email inbox.
· Pass/Fail: Pass/Fail status depends on how the expected result and the actual result compare to each other.
Same result = Pass
Different results = Fail
Hope you would have gained a good understanding of the concept of Test Cases. Check out our series of articles to know more about test cases and share your views in the comments!