Writing a test case involves specifying the input, the expected outcome, and the conditions under which the test will be conducted. Here's a template and some guidelines to help you write effective test cases:
Test Case Template:
Test Case ID: Unique identifier for the test case.
Title/Description: A brief, descriptive title or description of the test case.
Preconditions: Any necessary conditions that must be met before the test can be executed.
Test Steps:
- Step 1: Describe the specific action or input.
- Step 2: Another action or input.
- ...
Expected Result: Clearly define the expected outcome or behavior.
Postconditions: Any conditions that should be true after the test has been executed.
Test Data: Input data used for the test case.
Priority: The priority level of the test case (e.g., High, Medium, Low).
Test Environment: The specific environment or configuration in which the test will be conducted.
Test Case Execution: Record the results of the test (Pass/Fail/Blocked) and any comments.
Example:
Test Case ID: TC001
Title/Description: Verify successful login with valid credentials.
Preconditions: User account exists, and the user is on the login page.
Test Steps:
- Enter a valid username.
- Enter a valid password.
- Click on the "Login" button.
Expected Result: The user should be successfully logged in and redirected to the home page.
Postconditions: The user is logged in, and the home page is displayed.
Test Data:
- Username: test user
- Password: Test@123
Priority: High
Test Environment: Web application on the latest version of Chrome.
Test Case Execution:
- Result: Pass
- Comments: The user was successfully logged in, and the home page was displayed.
Guidelines for Writing Test Cases:
Be Clear and Specific:
- Use clear and concise language.
- Avoid ambiguity in your instructions.
Test One Thing at a Time:
- Each test case should focus on testing one specific functionality or scenario.
Use Realistic Data:
- Use realistic and relevant test data that represents actual usage.
Include Preconditions and Postconditions:
- Clearly state the conditions that must be met before and after the test.
Define Expected Results:
- Specify what the expected outcome should be for each step and for the overall test.
Prioritize Test Cases:
- Prioritize test cases based on their importance and impact.
Consider Negative Scenarios:
- Include test cases that cover potential errors or invalid inputs.
Keep It Simple:
- Avoid unnecessary complexity in your test cases.
Reusable and Maintainable:
- Write test cases in a way that they can be easily reused and maintained.
Review and Validate:
- Have others review your test cases to ensure clarity and accuracy.
Remember, the goal is to ensure comprehensive coverage and identify any issues or bugs in the software. Test cases are essential for maintaining the reliability and quality of a software application.
Writing test cases for a typical e-commerce flow involving sign-up, login, adding items to the cart, and checking out requires careful consideration and a systematic approach. Here's a general guide on how you can write test cases for each step:
Sign Up:
Test Case 1: Verify that a new user can successfully register with valid details.
- Description: Enter valid information (unique username, valid email, secure password) and confirm successful registration.
- Expected Result: The user should be registered successfully, and a confirmation message should be displayed.
Test Case 2: Verify that the system displays an error message if the user tries to sign up with an existing email address.
- Description: Attempt to register with an email address that is already in use.
- Expected Result: The system should display an error message indicating that the email is already registered.
Test Case 3: Check the validation of mandatory fields (e.g., username, password, email).
- Description: Submit the registration form with missing or invalid information.
- Expected Result: The system should display appropriate error messages for each missing or invalid field.
Test Case 4: Verify that the password meets the security requirements.
- Description: Attempt to register with a password that does not meet security criteria (e.g., minimum length, special characters).
- Expected Result: The system should prompt the user to enter a password meeting the security requirements.
Test Case 5: Check if the system sends a confirmation email upon successful registration.
- Description: Confirm that a confirmation email is sent to the registered email address.
- Expected Result: The user should receive an email with a confirmation link.
- Login:
Test Case 6: Confirm that a registered user can log in with valid credentials.
- Description: Enter the correct username and password and attempt to log in.
- Expected Result: The user should be successfully logged in and redirected to the home page.
Test Case 7: Verify that the system displays an error message for invalid login credentials.
- Description: Attempt to log in with incorrect username or password.
- Expected Result: The system should display an error message indicating invalid credentials.
Test Case 8: Test for account lockout after a certain number of unsuccessful login attempts.
- Description: Exceed the allowed number of unsuccessful login attempts.
- Expected Result: The user account should be locked, and a notification should be displayed. After a certain time or upon successful password reset, the account should be unlocked.
Test Case 9: Check the "Remember Me" functionality.
- Description: Log in with the "Remember Me" option selected and close the browser. Reopen the browser and navigate to the site.
- Expected Result: The user should be automatically logged in without entering credentials.
Test Case 10: Verify that the system redirects the user to the intended page after successful login.
- Description: After successful login, verify that the user is redirected to the page they were trying to access.
- Expected Result: The user should be redirected to the intended page.
- Add to Cart:
Test Case 11: Ensure that a user can add items to the cart from the product details page.
- Description: Click on the "Add to Cart" button for a product on the product details page.
- Expected Result: The product should be added to the cart, and the cart icon should be updated.
Test Case 12: Verify that the cart is updated when an item is added.
- Description: Add multiple items to the cart and verify that the cart reflects the correct quantity.
- Expected Result: The cart should display the correct number of items.
Test Case 13: Check if the system allows the user to update the quantity of items in the cart.
- Description: Change the quantity of an item in the cart and verify that the total reflects the update.
- Expected Result: The cart should update with the new quantity and display the correct total.
Test Case 14: Test the functionality of removing items from the cart.
- Description: Remove an item from the cart and verify that the cart is updated accordingly.
- Expected Result: The item should be removed from the cart, and the cart total should be adjusted.
Test Case 15: Verify that the cart reflects accurate prices and quantities.
- Description: Confirm that the prices and quantities displayed in the cart are accurate.
- Expected Result: The cart should display the correct prices and quantities for each item.
- Checkout:
Test Case 16: Ensure that the user can proceed to checkout from the cart.
- Description: Click on the "Proceed to Checkout" button from the cart page.
- Expected Result: The user should be directed to the checkout page.
Test Case 17: Verify that the system displays the correct shipping and billing information.
- Description: Complete the checkout process and verify that the shipping and billing information is accurate on the confirmation page.
- Expected Result: The confirmation page should display the correct shipping and billing details.
Test Case 18: Check the functionality of applying discount codes or coupons.
- Description: Enter a valid discount code during checkout.
- Expected Result: The system should apply the discount, and the total should reflect the reduced amount.
Test Case 19: Confirm that the user can select a shipping method.
- Description: During checkout, select a shipping method and proceed.
- Expected Result: The selected shipping method should be applied, and the user should be able to complete the purchase.
Test Case 20: Verify that the order summary is accurate before confirming the purchase.
- Description: Review the order summary on the confirmation page before confirming the purchase.
- Expected Result: The order summary should accurately reflect the items, quantities, prices, and total amount.
Considerations:
Data Independence:
- Ensure that each test case is designed to be executed independently, without relying on the outcome of other test cases.
Negative Testing:
- Include scenarios where users provide invalid or malicious input to ensure that the system handles errors securely.
Boundary Testing:
- Test with extreme values, such as the minimum and maximum allowed lengths for usernames, passwords, and other input fields.
Usability Testing:
- Evaluate the user interface for clarity, user-friendly error messages, and ease of navigation.
Concurrency Testing:
- Simulate scenarios where multiple users are performing actions simultaneously to identify and address any potential conflicts or issues.
Performance Testing:
- Measure the system's response time during peak usage periods to ensure it can handle the expected load.
Security Testing:
- Verify that user data is transmitted securely (using HTTPS) and that sensitive information is appropriately encrypted. Check for vulnerabilities such as SQL injection and cross-site scripting.
Cross-Browser and Cross-Device Testing:
- Ensure that the application works consistently across different browsers and devices to provide a seamless experience for users.
Regression Testing:
- Regularly execute test cases, especially after system updates or changes, to ensure that new features or modifications do not introduce unexpected issues.
By following this structured approach and considering these factors, you can develop comprehensive test cases that cover various aspects of the sign-up, login, add-to-cart, and checkout processes in an e-commerce application.
Read more narrative test case techniques:
Table Of Contents
What are test cases:
Why are test cases written:
Test cases and Test scenarios :
Who writes the test cases:
Test
Case template:
Use tools for automated testing:
Creating and Managing test cases through Testsigma:
Summary:
Frequently Asked Questions:
What are the main 5 required elements of a test case?
What are the 4 qualities of a test case?
How do I create a test case in Jira?
What are test cases:
A test case is a set of steps or instructions written to test a functionality or a feature of a software application. To do comprehensive testing of a software application, we need detailed test cases in place. Test cases are also the easiest way and part of the process where knowledge transfer is concerned. It can help the other person understand the application at an initial level.
Why are test cases written:
Test cases are usually written for the following reasons:
1. Preventing Bugs
3. Better test coverage
4. Identifying and documenting complex functionalities
5. Prioritizing them while releasing the product
Test cases and Test scenarios :
Test scenarios are usually derived from different aspects. It
usually gives information on what all parameters are considered for evaluating
the product. It can come from:
2. Customer feedback
3. Acceptance criteria
4. Assumptions for the undocumented requirements
6. Change requests
3. Data set to be used
Test cases are the detailed steps derived for the test
scenarios, which are to be documented to help the team increase their
efficiency and save time in the future wherein the team has to refer to the
past test cycles and identify missing scenarios.
Developers write the test cases as a part of the development
process which we call Unit tests. This gives us code coverage of the
module most impacted by the code change
Test Case template:
While writing a test case, a tester must have in mind to create a document that has the necessary information to execute and evaluate the test case status. A test usually consists of the below parameters.
1. Test case id: Each test must have a unique id that can be mapped to the Story id or Req id in the tool used in the team, which helps to keep track and calculate the test coverage. You can refer to a requirement document matrix for the same
2. Description: A brief description of what the functionality is about and test scenarios it is derived from, along with a brief idea of the business requirement, would be helpful for a new person to understand it in a better way
3. Module Name: The module to which the test steps belong, which helps us later to find out the dependent and impacted modules that need to be prioritized for testing.
4. Complexity: What is the complexity of the test case? It can be (Simple, Medium, or Complex), which helps us to decide which one to pick first when a time crunch is there. We can simply filter out the complex scenarios and plan the testing.
5. Preconditions: The ideal environment to perform the steps for both positive and negative scenarios.
6. Test steps: Detailed steps which are followed by the user to perform the actions intended.
7. Test Data: A comprehensive test data set that the user has to use to execute the test case. It can be dummy data created in lower environments, but it is always preferred to use real user data to get a better output.
8. Expected Results: The result expected after completing the steps. It can be a message or another landing page, an error message (in case of a negative test case), or a confirmation message (for a successful transaction).
9. Actual Result: Capturing the system’s behavior after the steps are performed and comparing it to the expected result
10. Status: Set the status as PASS/Fail as per the previous step result. If the status is failed create and tag the bug for the specific test case
11. Priority: We need to set the priority of the test cases based on conditions like functionality which has the greatest impact on major workflows of a system and to be executed at all times or based on risks and coverage and functionalities which have less impact and can be neglected for a release.
Few best practices to follow while writing test cases:
1. Aim for corner/edge case scenarios
2. Write the test steps precisely focusing on the scope
3. Attach and refer relevant test data or documents needed to
be referred to in any step
Creating and Managing test cases through Testsigma:
To write, execute and maintain automated test cases, Testsigma
offers a user-friendly platform where one can create different categories as
per the requirement.
Define Testcase type: Using the platform, users can automate different types of test cases such as UI, Functional, Nonfunctional, Integration, Regression, and Usability tests. These tests can be for web, mobile, desktop, or APIs.
Set priorities: Users also can set priorities (Critical, High, Medium, Low ) for the created test cases inside the tool. Users can create customized priorities such as (eg: supercritical).
Define the requirements: The user can also create its own requirement types from which the test case has been derived, as the requirements for the test cases come from different inputs.
Maintaining test cases can be a challenge in an agile environment, where requirements are subject to frequent changes. However, using automated tools can be valuable in such scenarios, allowing the team to adjust to changing requirements while keeping their test cases up-to-date.
Hope you find it useful
1. Gathering the right requirement criteria
2. Keep the user behavior in mind.
3. Prerequisites are the most important part of any test case
What are the 4 qualities of a test case?
1. Written in a precise and concise way
2. Easy to understand for everyone
3. Covers all aspects of testing
4. Easy to maintain
How do I create a test case in Jira?
1. Log into your Jira account and navigate to the project where you want to add the test cases.
2. Click on the “Issues” tab in the top navigation bar.
3. Select “Create Issue” to create a new issue.
4. In the “Create Issue” form, select the issue type as “Test”.
5. Fill in the required information such as summary, description, and any other relevant fields.
6. In the description or comments section, you can provide detailed steps for the test case, expected results, and any other necessary information.
7. Assign the issue to the appropriate team member responsible for executing the test case by selecting their name from the “Assignee” field.
8. Set the priority and other relevant fields based on your project’s requirements.
9. If necessary, you can attach files or screenshots to the test case by using the “Attachments” section.
10. Save the issue to create the test case in Jira.
11. Repeat the above steps for each additional test case you
want to add.