How to Write Test Cases for Account Deletion (With Examples)
Writing test cases for account deletion is a critical aspect of ensuring that your application handles user data securely and efficiently. Account deletion is a sensitive operation that can have signi
How to Write Test Cases for Account Deletion (With Examples)
Writing test cases for account deletion is a critical aspect of ensuring that your application handles user data securely and efficiently. Account deletion is a sensitive operation that can have significant implications for user trust and compliance with data protection regulations. This guide will walk you through the process of creating high-signal test cases for account deletion, covering the anatomy of a test case, positive and negative scenarios, edge and boundary cases, and a comprehensive set of 20+ example test cases. We'll also discuss data setup, prioritization, and traceability to requirements, as well as how combining designed test cases with autonomous exploration can provide real coverage.
Understanding the Anatomy of a Test Case
Before diving into specific test cases, it's essential to understand the structure of a test case. A well-written test case typically includes the following components:
Test Case ID
A unique identifier for the test case, which helps in tracking and referencing.
Title
A brief, descriptive title that summarizes the purpose of the test case.
Description
A detailed description of what the test case aims to verify or validate.
Pre-conditions
The conditions that must be true before the test case can be executed. This might include user roles, data setup, and system states.
Test Steps
A step-by-step guide on how to execute the test case.
Expected Result
The expected outcome of the test case, including any specific assertions or validations.
Post-conditions
The conditions that should be true after the test case is executed.
Priority
The importance of the test case, which helps in prioritizing execution.
Status
The current status of the test case (e.g., Passed, Failed, Blocked).
Positive Test Cases for Account Deletion
Positive test cases are designed to verify that the system behaves as expected under normal conditions. Here are some examples:
Test Case 1: Successful Account Deletion
ID: TC-01
Title: Successful Account Deletion
Description: Verify that a user can successfully delete their account.
Pre-conditions:
- User is logged in.
- User has an active account.
Test Steps:
- Navigate to the account settings page.
- Click on the "Delete Account" button.
- Confirm the deletion by clicking "Yes, Delete Account."
Expected Result:
- The user's account is deleted.
- The user is logged out.
- A confirmation message is displayed.
Post-conditions:
- User data is removed from the system.
Priority: High
Test Case 2: Account Deletion Confirmation
ID: TC-02
Title: Account Deletion Confirmation
Description: Verify that the user is prompted to confirm the account deletion.
Pre-conditions:
- User is logged in.
- User has an active account.
Test Steps:
- Navigate to the account settings page.
- Click on the "Delete Account" button.
Expected Result:
- A confirmation dialog is displayed asking the user to confirm the deletion.
Post-conditions:
- No changes to the user's account.
Priority: High
Negative Test Cases for Account Deletion
Negative test cases are designed to verify that the system behaves correctly under abnormal or unexpected conditions. Here are some examples:
Test Case 3: Account Deletion Without Confirmation
ID: TC-03
Title: Account Deletion Without Confirmation
Description: Verify that the account is not deleted if the user does not confirm the deletion.
Pre-conditions:
- User is logged in.
- User has an active account.
Test Steps:
- Navigate to the account settings page.
- Click on the "Delete Account" button.
- Click "Cancel" in the confirmation dialog.
Expected Result:
- The user's account is not deleted.
- The user remains logged in.
Post-conditions:
- No changes to the user's account.
Priority: High
Test Case 4: Account Deletion for Logged Out User
ID: TC-04
Title: Account Deletion for Logged Out User
Description: Verify that a logged-out user cannot access the account deletion functionality.
Pre-conditions:
- User is logged out.
Test Steps:
- Navigate to the account settings page.
Expected Result:
- The user is redirected to the login page.
Post-conditions:
- No changes to the user's account.
Priority: High
Edge and Boundary Cases for Account Deletion
Edge and boundary cases are designed to test the limits of the system and identify any potential issues. Here are some examples:
Test Case 5: Account Deletion for New User
ID: TC-05
Title: Account Deletion for New User
Description: Verify that a user can delete their account immediately after creating it.
Pre-conditions:
- User has just created an account and is logged in.
Test Steps:
- Navigate to the account settings page.
- Click on the "Delete Account" button.
- Confirm the deletion by clicking "Yes, Delete Account."
Expected Result:
- The user's account is deleted.
- The user is logged out.
- A confirmation message is displayed.
Post-conditions:
- User data is removed from the system.
Priority: Medium
Test Case 6: Account Deletion for User with Pending Transactions
ID: TC-06
Title: Account Deletion for User with Pending Transactions
Description: Verify that a user cannot delete their account if they have pending transactions.
Pre-conditions:
- User is logged in.
- User has an active account with pending transactions.
Test Steps:
- Navigate to the account settings page.
- Click on the "Delete Account" button.
Expected Result:
- An error message is displayed indicating that the account cannot be deleted due to pending transactions.
Post-conditions:
- No changes to the user's account.
Priority: High
Example Test Matrix for Account Deletion
To provide a clear overview, here is a test matrix with 20+ example test cases for account deletion:
| ID | Title | Pre-conditions | Test Steps | Expected Result | Post-conditions | Priority |
|---|---|---|---|---|---|---|
| TC-01 | Successful Account Deletion | User is logged in, user has an active account. | 1. Navigate to the account settings page. 2. Click on the "Delete Account" button. 3. Confirm the deletion. | The user's account is deleted. The user is logged out. A confirmation message is displayed. | User data is removed from the system. | High |
| TC-02 | Account Deletion Confirmation | User is logged in, user has an active account. | 1. Navigate to the account settings page. 2. Click on the "Delete Account" button. | A confirmation dialog is displayed. | No changes to the user's account. | High |
| TC-03 | Account Deletion Without Confirmation | User is logged in, user has an active account. | 1. Navigate to the account settings page. 2. Click on the "Delete Account" button. 3. Click "Cancel" in the confirmation dialog. | The user's account is not deleted. The user remains logged in. | No changes to the user's account. | High |
| TC-04 | Account Deletion for Logged Out User | User is logged out. | 1. Navigate to the account settings page. | The user is redirected to the login page. | No changes to the user's account. | High |
| TC-05 | Account Deletion for New User | User has just created an account and is logged in. | 1. Navigate to the account settings page. 2. Click on the "Delete Account" button. 3. Confirm the deletion. | The user's account is deleted. The user is logged out. A confirmation message is displayed. | User data is removed from the system. | Medium |
| TC-06 | Account Deletion for User with Pending Transactions | User is logged in, user has an active account with pending transactions. | 1. Navigate to the account settings page. 2. Click on the "Delete Account" button. | An error message is displayed indicating that the account cannot be deleted due to pending transactions. | No changes to the user's account. | High |
| TC-07 | Account Deletion for Admin User | Admin user is logged in, admin user has an active account. | 1. Navigate to the account settings page. 2. Click on the "Delete Account" button. 3. Confirm the deletion. | The admin user's account is deleted. The user is logged out. A confirmation message is displayed. | Admin user data is removed from the system. | High |
| TC-08 | Account Deletion for User with Multiple Accounts | User is logged in, user has multiple linked accounts. | 1. Navigate to the account settings page. 2. Click on the "Delete Account" button. 3. Confirm the deletion. | The user's account is deleted. The user is logged out. A confirmation message is displayed. | User data is removed from the system, but other linked accounts remain. | Medium |
| TC-09 | Account Deletion for User with Subscriptions | User is logged in, user has an active account with active subscriptions. | 1. Navigate to the account settings page. 2. Click on the "Delete Account" button. | An error message is displayed indicating that the account cannot be deleted due to active subscriptions. | No changes to the user's account. | High |
| TC-10 | Account Deletion for User with Invoices | User is logged in, user has an active account with past invoices. | 1. Navigate to the account settings page. 2. Click on the "Delete Account" button. 3. Confirm the deletion. | The user's account is deleted. The user is logged out. A confirmation message is displayed. | User data is removed from the system, but past invoices are retained for audit. | Medium |
| TC-11 | Account Deletion for User with No Data | User is logged in, user has an active account with no data. | 1. Navigate to the account settings page. 2. Click on the "Delete Account" button. 3. Confirm the deletion. | The user's account is deleted. The user is logged out. A confirmation message is displayed. | User data is removed from the system. | Medium |
| TC-12 | Account Deletion for User with Social Media Links | User is logged in, user has an active account linked to social media. | 1. Navigate to the account settings page. 2. Click on the "Delete Account" button. 3. Confirm the deletion. | The user's account is deleted. The user is logged out. A confirmation message is displayed. | User data is removed from the system, but social media links are retained. | Medium |
| TC-13 | Account Deletion for User with Two-Factor Authentication | User is logged in, user has an active account with two-factor authentication. | 1. Navigate to the account settings page. 2. Click on the "Delete Account" button. 3. Confirm the deletion. | The user's account is deleted. The user is logged out. A confirmation message is displayed. | User data is removed from the system. | High |
| TC-14 | Account Deletion for User with Inactive Account | User is logged in, user has an inactive account. | 1. Navigate to the account settings page. 2. Click on the "Delete Account" button. 3. Confirm the deletion. | The user's account is deleted. The user is logged out. A confirmation message is displayed. | User data is removed from the system. | Medium |
| TC-15 | Account Deletion for User with Locked Account | User is logged in, user has an active account that is locked. | 1. Navigate to the account settings page. 2. Click on the "Delete Account" button. | An error message is displayed indicating that the account is locked and cannot be deleted. | No changes to the user's account. | High |
| TC-16 | Account Deletion for User with Pending Support Requests | User is logged in, user has an active account with pending support requests. | 1. Navigate to the account settings page. 2. Click on the "Delete Account" button. | An error message is displayed indicating that the account cannot be deleted due to pending support requests. | No changes to the user's account. | High |
| TC-17 | Account Deletion for User with Suspended Account | User is logged in, user has an active account that is suspended. | 1. Navigate to the account settings page. 2. Click on the "Delete Account" button. | An error message is displayed indicating that the account is suspended and cannot be deleted. | No changes to the user's account. | High |
| TC-18 | Account Deletion for User with Custom Data | User is logged in, user has an active account with custom data. | 1. Navigate to the account settings page. 2. Click on the "Delete Account" button. 3. Confirm the deletion. | The user's account is deleted. The user is logged out. A confirmation message is displayed. | User data is removed from the system, but custom data is retained. | Medium |
| TC-19 | Account Deletion for User with Large Data Volume | User is logged in, user has an active account with a large volume of data. | 1. Navigate to the account settings page. 2. Click on the "Delete Account" button. 3. Confirm the deletion. | The user's account is deleted. The user is logged out. A confirmation message is displayed. | User data is removed from the system. | Medium |
| TC-20 | Account Deletion for User with Reverted Deletion | User is logged in, user has an active account that was previously deleted and restored. | 1. Navigate to the account settings page. 2. Click on the "Delete Account" button. 3. Confirm the deletion. | The user's account is deleted. The user is logged out. A confirmation message is displayed. | User data is removed from the system. | Medium |
Data Setup for Account Deletion Test Cases
Data setup is crucial for ensuring that your test cases are accurate and reliable. Here are some tips for setting up data for account deletion test cases:
Creating Test Users
- New User: Create a new user account and verify that it is active.
- User with Pending Transactions: Create a user account and simulate pending transactions.
- User with Pending Support Requests: Create a user account and simulate pending support requests.
- User with Subscriptions: Create a user account and subscribe them to various services.
- User with Invoices: Create a user account and generate past invoices.
Setting Up User Roles
- Admin User: Create an admin user account with elevated privileges.
- Locked Account: Create a user account and lock it.
- Suspended Account: Create a user account and suspend it.
Handling Special Cases
- User with No Data: Create a user account with no associated data.
- User with Custom Data: Create a user account with custom data that should be retained.
- User with Large Data Volume: Create a user account with a large volume of data.
Prioritizing Test Cases for Account Deletion
Prioritizing test cases ensures that the most critical scenarios are tested first. Here are some guidelines for prioritizing account deletion test cases:
High Priority
- TC-01: Successful Account Deletion
- TC-02: Account Deletion Confirmation
- TC-03: Account Deletion Without Confirmation
- TC-04: Account Deletion for Logged Out User
- TC-06: Account Deletion for User with Pending Transactions
- TC-09: Account Deletion for User with Subscriptions
- TC-15: Account Deletion for User with Locked Account
- TC-16: Account Deletion for User with Pending Support Requests
- TC-17: Account Deletion for User with Suspended Account
Medium Priority
- TC-05: Account Deletion for New User
- TC-07: Account Deletion for Admin User
- TC-08: Account Deletion for User with Multiple Accounts
- TC-10: Account Deletion for User with Invoices
- TC-11: Account Deletion for User with No Data
- TC-12: Account Deletion for User with Social Media Links
- TC-13: Account Deletion for User with Two-Factor Authentication
- TC-14: Account Deletion for User with Inactive Account
- TC-18: Account Deletion for User with Custom Data
- TC-19: Account Deletion for User with Large Data Volume
- TC-20: Account Deletion for User with Reverted Deletion
Low Priority
- TC-08: Account Deletion for User with Multiple Accounts
Traceability to Requirements
Ensuring that test cases are traceable to requirements is essential for maintaining the quality of your testing process. Here is a sample traceability matrix:
| Test Case ID | Requirement ID | Requirement Description |
|---|---|---|
| TC-01 | REQ-01 | User can delete their account. |
| TC-02 | REQ-02 | User must confirm account deletion. |
| TC-03 | REQ-02 | User must confirm account deletion. |
| TC-04 | REQ-03 | Only logged-in users can access account deletion. |
| TC-05 | REQ-01 | User can delete their account immediately after creation. |
| TC-06 | REQ-04 | User cannot delete their account if they have pending transactions. |
| TC-07 | REQ-01 | Admin user can delete their account. |
| TC-08 | REQ-05 | User can delete one of their multiple accounts. |
| TC-09 | REQ-06 | User cannot delete their account if they have active subscriptions. |
| TC-10 | REQ-07 | User can delete their account even if they have past invoices. |
| TC-11 | REQ-08 | User can delete their account even if they have no data. |
| TC-12 | REQ-09 | User can delete their account even if they have social media links. |
| TC-13 | REQ-10 | User can delete their account even if they have two-factor authentication. |
| TC-14 | REQ-11 | User can delete their account even if it is inactive. |
| TC-15 | REQ-12 | User cannot delete their account if it is locked. |
| TC-16 | REQ-13 | User cannot delete their account if they have pending support requests. |
| TC-17 | REQ-14 | User cannot delete their account if it is suspended. |
| TC-18 | REQ-15 | User can delete their account even if they have custom data. |
| TC-19 | REQ-16 | User can delete their account even if they have a large volume of data. |
| TC-20 | REQ-17 | User can delete their account even if it was previously deleted and restored. |
Combining Designed Test Cases with Autonomous Exploration
While designed test cases provide a structured approach to testing, they may not cover all possible scenarios, especially edge cases that only show up in production. This is where autonomous exploration tools like SUSA can be incredibly valuable.
How SUSA Works
SUSA is an autonomous QA platform that explores your application without the need for scripts. It taps, scrolls, types, and handles dialogs, completing real user flows. SUSA tests with a range of user personas (curious, impatient, novice, adversarial, elderly, accessibility, power user, and others), each with its own behavior profile. It finds crashes, ANRs, dead buttons, accessibility (WCAG) violations, security issues, and UX friction in a single pass.
Integrating SUSA with Designed Test Cases
- Upload Your APK or Web URL: Use SUSA to explore your application by uploading an APK or pointing it at a web URL.
- Run Autonomous Exploration: SUSA will explore the application, handling various user flows and scenarios.
- Review Results: SUSA provides detailed reports on issues found, including crashes, ANRs, and UX friction.
- Generate Regression Scripts: SUSA auto-generates regression scripts from what it discovered, using Appium for Android and Playwright for web.
- Combine Results: Use the results from SUSA to supplement your designed test cases, ensuring comprehensive coverage.
Example: Combining SUSA with TC-06
For the test case TC-06: Account Deletion for User with Pending Transactions, SUSA can help by:
- Exploring Edge Cases: SUSA might discover that certain combinations of pending transactions (e.g., multiple pending payments, pending refunds) cause the account deletion to fail in ways not covered by the designed test case.
- Identifying UX Friction: SUSA can identify if the confirmation dialog for account deletion is not prominent enough or if the error messages are unclear.
- Generating Additional Test Cases: SUSA can generate additional test cases based on the scenarios it explored, which can be added to your test suite.
Manual and Automated Approaches
Combining manual and automated testing is crucial for ensuring robust coverage of account deletion scenarios. Here’s how you can approach both:
Manual Testing
Manual testing involves human testers executing the test cases step by step. This approach is useful for:
- Exploring Edge Cases: Human testers can think creatively and identify edge cases that automated tests might miss.
- User Experience Testing: Manual testing allows for a more subjective evaluation of the user experience.
Automated Testing
Automated testing involves using tools and scripts to execute test cases. This approach is useful for:
- Reproducibility: Automated tests can be run consistently and repeatedly, ensuring that the same scenarios are tested each time.
- Scalability: Automated tests can be run on multiple devices and environments, increasing coverage.
Example: Automating TC-01 with Appium
Here’s an example of how you can automate TC-01: Successful Account Deletion using Appium:
from appium import webdriver
import unittest
class TestAccountDeletion(unittest.TestCase):
def setUp(self):
desired_caps = {}
desired_caps['platformName'] = 'Android'
desired_caps['deviceName'] = 'Android Emulator'
desired_caps['appPackage'] = 'com.example.app'
desired_caps['appActivity'] = '.MainActivity'
self.driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps)
def test_account_deletion(self):
# Log in
self.driver.find_element_by_id('login_email').send_keys('user@example.com')
self.driver.find_element_by_id('login_password').send_keys('password')
self.driver.find_element_by_id('login_button').click()
# Navigate to account settings
self.driver.find_element_by_id('settings_button').click()
# Click on delete account
self.driver.find_element_by_id('delete_account_button').click()
# Confirm deletion
self.driver.find_element_by_id('confirm_delete_button').click()
# Verify account deletion
self.assertTrue(self.driver.find_element_by_id('confirmation_message').text == 'Account deleted successfully.')
def tearDown(self):
self.driver.quit()
if __name__ == '__main__':
unittest.main()
Real-World Edge Cases
In production, you might encounter edge cases that are not immediately obvious. Here are some real-world edge cases to consider:
Edge Case 1: User with Multiple Accounts Linked to the Same Email
- Scenario: A user has multiple accounts linked to the same email address.
- Test Case: Verify that deleting one account does not affect the others.
Edge Case 2: User with Custom Data Retention Requirements
- Scenario: A user has custom data that should be retained even after account deletion.
- Test Case: Verify that the custom data is retained as per the user’s preferences.
Edge Case 3: User with Large Volume of Data
- Scenario: A user has a large volume of data that might take a long time to delete.
- Test Case: Verify that the account deletion process handles large volumes of data efficiently and does not timeout.
Edge Case 4: User with Inactive Account
- Scenario: A user has an inactive account that has not been used for a long time.
- Test Case: Verify that the account can still be deleted, and the user is logged out.
Edge Case 5: User with Suspended Account
- Scenario: A user has a suspended account due to policy violations.
- Test Case: Verify that the account cannot be deleted and that the user receives an appropriate error message.
Short Checklist for Account Deletion Test Cases
Here is a short checklist to ensure you cover all essential aspects of account deletion testing:
- Positive Scenarios:
- Can a user successfully delete their account?
- Is the user prompted to confirm the account deletion?
- Is the user logged out after account deletion?
- Is a confirmation message displayed?
- Negative Scenarios:
- Can a user delete their account without confirmation?
- Can a logged-out user access the account deletion functionality?
- Can a user delete their account if they have pending transactions?
- Can a user delete their account if they have active subscriptions?
- Edge and Boundary Cases:
- Can a new user delete their account immediately after creation?
- Can a user delete their account if they have a large volume of data?
- Can a user delete their account if they have custom data retention requirements?
- Can a user delete their account if it is inactive or suspended?
- Data Setup:
- Are test users created with the necessary data and roles?
- Are the test environments properly set up?
- Prioritization:
- Are high-priority test cases executed first?
- Traceability:
- Are test cases traceable to requirements?
- Automation:
- Are critical test cases automated for reproducibility and scalability?
Closing Takeaways
Writing test cases for account deletion is a critical aspect of ensuring the security and reliability of your application. By covering positive, negative, edge, and boundary cases, you can ensure that your application handles account deletion correctly under various scenarios. Combining designed test cases with autonomous exploration tools like SUSA can provide comprehensive coverage and help identify issues that might not be apparent through manual testing alone.
Remember to prioritize your test cases, ensure traceability to requirements, and automate critical scenarios for consistent and reliable testing. By following these best practices, you can build a robust testing strategy that enhances user trust and compliance with data protection regulations.
Test Your App Autonomously
Upload your APK or URL. SUSA explores like 10 real users — finds bugs, accessibility violations, and security issues. No scripts.
Try SUSA Free