Would you know what to do if you were asked to write a test case? and how to do it properly.
What about a test case and test scenario? Do you know the difference between them?
Before discussing the characteristics of a good test case, let’s first define these terms.
Test scenarios and Test cases imply a different level of detail. Once a tester knows what each of these terms means, they can understand how to use them to describe the testing work that is done on a daily basis.
Test scenarios and test cases are regrouped under a high document, the test plan defined in a previous article.
What is a test scenario?
A test scenario is basically a documentation of a use case. It describes the application’s functionality to be tested. It is used to test a feature end-to-end.
The same test scenario will require one or more test cases to ensure that the procedure has been covered satisfactorily. Therefore, a test scenario has a one-to-many relationship with test cases.
As an example, consider a test scenario.
“Verify that the user cannot log in with incorrect credentials.”
Now, this test scenario can be further decomposed into several test cases:
- Verify that a user with the correct username and password is not authorized to log in.
- Verify that a user with an incorrect username and correct password is not allowed to log in.
- Verify that users with incorrect username and password cannot log in.
I think now the relation between the test scenario and the test case is clear, so let’s move to the purpose of this article.
What is a test case?
A test case is a set of actions performed to verify a particular feature or functionality of your software application.
It includes all possible positive and negative inputs, as well as test data and preconditions developed for a specific test case to verify any requirement.
Using these variables and conditions, the tester can compare actual and expected results to determine if a software product performs according to customer requirements.
As one of the best practices uses a traceability matrix to be sure that you covered all the applications.
A test case should be simple, precise and concise
Model, Representative for other test cases.
Don’t assume any functionality; the test case must be extracted from the customer’s requirements.
You can read about some test case authoring tips in the article here.
Basic elements to write a test case
1) Test Case ID
Test cases should all have unique identifiers to represent them. In most cases, following a convention for this naming ID help with organization, clarity, and understanding. Generally, it’s generated automatically using a test management tool.
2) Test Case Title
The test case title should be unique and as descriptive as possible; the best practice is to keep the name concise (a phrase ) for readability example: Login using invalid credentials.
3) Description of the test
This description should detail what unit, feature or function is tested or what is verified.
4) Preconditions and prerequisites
This implies all the conditions to be met before the execution of the test case. example, if you try to connect to an application, a user account must be created as a precondition.
5) Test Data
This concerns the variables and their values in the test case. The test data used in testing must be diverse and close to real-time usage. In the example of an email login, this would be the account username and password.
6) Steps to perform
These should be easily repeatable steps performed from the end user’s perspective. For example, considering the same test case, log in to an application might include the following steps:
- Go to the URL application.
- Enter your username.
- Enter password.
- Click on the “login” button.
7) Expected results
This indicates the expected result after running the test case step by entering the correct login information. we should mention that every step has an excepted result.
Test case writing varies depending on what the test case is verifying or testing. Hopefully, this article will help you to write effective test cases for your projects.
We are inviting passionate testers in the community to join our team and help us move closer to the vision behind Synapse QA. If you enjoy the experience of giving back to the community & helping others grow, this opportunity is for YOU! Please submit your interest in the form by clicking the button below: