Introduction
SQL test cases for banking application help QA testers verify account balances, money transfers, deposits, withdrawals, and transaction history. Banking applications handle sensitive financial data, so testers must ensure that every transaction is processed correctly and database records remain accurate.
Banking applications handle important financial activities such as money transfers, deposits, withdrawals, balance checks, and transaction history. Even a small error in a banking application can affect customer accounts and financial records.
As a software tester, you need to verify not only the application’s user interface but also the data stored in the database. This is where SQL testing becomes useful.
SQL testing helps testers check whether the correct data is stored, updated, retrieved, and deleted in the database.
In this blog, we will explore important SQL test cases for a banking application with simple examples that beginners can understand and practice.
What Is SQL Testing in Banking Applications?
SQL testing is the process of validating database operations using SQL queries.
For example, when a customer transfers ₹5,000 from one bank account to another, the application should:
- Deduct ₹5,000 from the sender’s account.
- Add ₹5,000 to the receiver’s account.
- Store the transaction details correctly.
- Update the transaction status.
- Maintain accurate account balances.
A QA tester can use SQL queries to verify these database changes.
Important SQL Test Cases for Banking Application
Before writing SQL test cases, let’s assume our banking application has the following database tables.
1. Customers Table
| customer_id | customer_name | status |
|---|---|---|
| 101 | Amit Sharma | Active |
| 102 | Priya Patil | Active |
| 103 | Rahul Verma | Inactive |
2. Accounts Table
| account_id | customer_id | balance |
|---|---|---|
| 1001 | 101 | 20000 |
| 1002 | 102 | 15000 |
| 1003 | 103 | 5000 |
3. Transactions Table
| transaction_id | from_account | to_account | amount | status |
|---|---|---|---|---|
| 501 | 1001 | 1002 | 2000 | Success |
| 502 | 1001 | 1003 | 1000 | Failed |
Note: These tables and records are sample data created for learning purposes.
Important SQL Test Cases for a Banking Application
Test Case 1: Verify Customer Details
Objective: Verify that customer information is stored correctly in the database.
SQL query:
SELECT *
FROM Customers
WHERE customer_id = 101;
Expected result:
The query should return the correct customer record, including the customer ID, name, and status.
What should a tester check?
- The customer ID should be correct.
- The customer name should match the application.
- The customer status should be accurate.
Test Case 2: Verify Account Balance
Objective: Check whether the account balance displayed in the application matches the database.
SQL query:
SELECT account_id, balance
FROM Accounts
WHERE account_id = 1001;
Expected result:
The account balance should be ₹20,000, based on the sample data.
What should a tester check?
- The correct account should be returned.
- The balance should match the application’s displayed balance.
- The balance should not change without a valid transaction.
Test Case 3: Verify Money Transfer
Objective: Verify whether the sender’s and receiver’s balances are updated correctly after a successful transfer.
Suppose the sender transfers ₹2,000 to the receiver.
SQL query:
SELECT account_id, balance
FROM Accounts
WHERE account_id IN (1001, 1002);
Expected result:
If the initial balances were ₹20,000 and ₹15,000, the expected balances after a successful transfer would be:
- Sender’s balance: ₹18,000
- Receiver’s balance: ₹17,000
The tester should also verify that the transfer is recorded successfully in the Transactions table.
Test Case 4: Verify Transaction History
Objective: Ensure that the transaction history contains the correct details.
SQL query:
SELECT *
FROM Transactions
WHERE from_account = 1001;
Expected result:
The query should return the transactions associated with the sender’s account.
What should a tester check?
- Transaction ID should be correct.
- Sender and receiver account IDs should be accurate.
- The transaction amount should be correct.
- The transaction status should match the application’s result.
Test Case 5: Verify Failed Transactions
Objective: Ensure that a failed transaction does not incorrectly reduce the sender’s balance or increase the receiver’s balance.
SQL query:
SELECT *
FROM Transactions
WHERE transaction_id = 502;
Expected result:
The transaction status should be Failed.
The tester should also compare account balances before and after the failed transaction to confirm that no unintended money movement occurred.
Test Case 6: Verify Insufficient Balance
Objective: Check whether the application prevents a customer from transferring more money than the available balance.
Suppose an account has ₹5,000, and the customer tries to transfer ₹8,000.
SQL query:
SELECT balance
FROM Accounts
WHERE account_id = 1003;
Expected result:
The application should reject the transfer if the available balance is insufficient and the applicable banking rules do not permit overdrawing.
The account balance should remain unchanged, and the failed attempt should be recorded according to the application’s transaction and audit requirements.