What is way of writing testcases for database testing?

Questions by rbabu.vobilisetti

Showing Answers 1 - 21 of 21 Answers

Supriya Gainder

  • Sep 21st, 2005

For writing test cases in Database first one should define the project name, then module,Bug number,objective,steps/action undertaken,expected result,actual result, then status, priority and severity.

Supriya Gainder

  • Sep 21st, 2005

For writing test cases in Database first one should define the project name, then module, Bug number, objective, steps/action undertaken, expected result, actual result, then status, priority and severity.


  • Dec 30th, 2005

Also specify the functions, stored procedures used, table/view or control structures causing the error if you can identify.

  Was this answer useful?  Yes

Sriram Kammisetty

  • Jan 12th, 2006


You wrote an answer how to log bug but not for how to write test case for databas testing.


Sriram Kammisetty

  • Jan 12th, 2006

Normallyl how do we write the test cases for different applications as same as Database testing also (inputs and Outputs and expected results) .Am i right please correct me


  • Jan 14th, 2006

You have to do the following for writing the database testcases.

1. First of all you have to understand the functional requirement of the application throughly.

2. Then you have to find out the back end tables used, joined used between the tables, cursors used (if any), tiggers used(if any), stored procedures used (if any), input parmeter used and output parameters used for developing that requirement.

3. After knowing all these things you have to write the testcase with different input values for checking all the paths of SP.

One thing writing testcases for backend testing not like functinal testing. You have to use white box testing techniques.


Niranjan Reddy

  • Mar 10th, 2006

To write testcase for database its just like functional testing.1.Objective:Write the objective that you would like to test. eg: To check the shipment that i load thru xml is getting inserted for perticular customer.2.Write the method of input or action that you do. eg:Load an xml with all data which can be added to a customer.3.Expected :Input should be viewd in database. eg: The shipment should be loaded sucessfully for that customer,also it should be seen in application.4.You can write ssuch type of testcases for any functionality like update,delete etc.

  Was this answer useful?  Yes


  • Jul 4th, 2006

Hi all,

At first we need to go through the documents provided. Need to know what tables, stored procedures are mentioned in the doc. Then test the functionality of the application. Simultaneously, start writing the DB testcases.. with the queries you have used at the backend while testing, the tables and stored procedures you have used in order to get the desired results. Trigers that were fired. Based on the stored procedure we can know the functionality for a specific peice of the application. So that we can write queries related to that. From that we make DB testcases also.

Correct me if i am wrong....



Sunil Wudharu

  • Sep 5th, 2006

Can anybody give an example of Database TestCase with a scenario?


  • Jan 31st, 2007

In order to create database test cases, you can have two different aproaches, performing both of them is advisable, if time permits.1) Testing each and every Trigger, Cursor, SP used in the application.2) Testing the application w.r.t functionality of the application, like for example:Let's say there are two web sites, type 'ABC' records should be displayed only in ABC websiteand type 'XYZ' records should be displayed only in XYZ website. You can insert a new type 'ABC' record and see if it is displayed only on ABC website and not on XYZ website.Both the websites are controlled by the same company, it just wants type I customers to have acces to type I website and Type II customers have access to type II website. This is a completely imaginary example, there can be any type of application or service functionality which can be broken down in to test cases in turn.Hope this from now on for anyone will be of good help.ThanksPranav CHyderabad.


  • Mar 8th, 2007

Hi to all
   All ur info is very useful but i need some more explanation reg testcase for database testing so anyone can tel me with real example and i need the format of database testcase with one example
Thanks and am eagerly waitin for ur reply

  Was this answer useful?  Yes


  • Jul 3rd, 2007

Writing test cases for db testing involves undersanding the requirement first, then writing a SQL query to validate the requirement and some input values which will be used as test data. Try having some idea from the example below.

There is a Shopping website from where users can buy products. When a user buys a product, an electronic invoice is generated with a transaction number.

Testing the transaction no so that the no generated in the (invoice) website is the same which gets populated into the database.

select * from Tab_Name where Trans_id=''Txxxxxxxxxxxx001 ;

sample of a test case worksheet:
test_case_id | Source Document | input data | test case description | Execution Steps | Expected results| Remarks.........................blah blah

1  | SRS.doc | Txxxxxxxxxxxx001 | some desc | select * from Tab_Name where Trans_id='';| only 1 row should be displayed|

So you can see,
test case id=1
source document= SRS.doc
input data=Txxxxxxxxxxxx001=this is the transaction no generated after you have bought an item from the website
 etc etc

Hope it's clear now.

For the same transaction no, you can do a lot of validations like checking length, Null values etc, all of which again depends upon requirement.


Gurudas Kulkarni

  • Jul 17th, 2007

Focus should be on Triggers,Tables,Cursors,Specfications,Time,Size,datatypes declared etc.

  Was this answer useful?  Yes


  • Jan 26th, 2008

If you ae testing a database application or web service that utilises a DB you have testing done from the front end as well as the back end.
 1. Front end testing is similiar to to functional testcase writing.
The only additional information would be the Table name , column etc that you would be refrencing.

2.If you are conducting a pure backend testing then, the testcase would deal purely with the table and queries that you are using to seed data and the expected outcome based on the same.
eg: if you have to validate a maintenace of history of updates , this is usually a scenario wherein on a update in a module there is a trigger fired  that does an update in a history maintened table.
To test this you need a SQl qury that does an update in a module refrenced table and on running that you need to manually check if the History mainted table is updated with the relevant information.

 DB testing can be done in two situation
      1) from the front end
      2) only on backend

    In the front end perspective, for example, i want to test the entered empno and ename is saving in the backend.
            i will enter empno, ename in the front end screen and clock on save.
           in this situation , 
                   i will add one more column name SQL in the template of T.C.D and i will add this query
                  select empno, ename from emp where ename=' abc';
   In the backend perspective,  for example i want to test empname abc is existed in the emp table or not.
            I will  write query for this as
 select * from  emp where ename='abc'



  • Jul 13th, 2008

just as a normal test case,

just with a seperate title as DB testing

here the execution steps would contain some sql queries and expected result needs to be validated w.r.t to  ui and back end.

  Was this answer useful?  Yes

I would say first learn the database, epecially the relationship among the table.
Try to understand the business rule
Try to understand the data
Start feeding data through the user interface
Open database verify movement of data
keep record  of your action in the test case field.

Note :You may want to start with table has less column or data.

  Was this answer useful?  Yes


  • Jun 2nd, 2011

Suppose we are performing web based testing and then we need to specify end to end scenario.
for example:There is a simple form page and after clicking on Save button the values should be stamped in Database.To verify this,Test case should have following:
1.Entry criteria
2.Steps to perform.
   2.1 Enter all the mandatory fields on the form page.
   2.2 Click on Save button
   2.3 Verify Database and specify query to perform database testing.
3.Exit criteria
4.Expected Result.
5.Actual Result.

  Was this answer useful?  Yes


  • Jul 28th, 2011

For writing db test cases, Understand the requirement, and then think about step name, step description, actual output, and expected output.

  Was this answer useful?  Yes

govind kumar

  • Aug 9th, 2011

For writing test cases in Database first one should define the project name, then module,Bug number,objective,steps/action undertaken,expected result,actual result, then status, priority and severity.

  Was this answer useful?  Yes


  • Nov 2nd, 2011

Ok lets do this by taking an example.

Lets say you are testing the integration between database and a user registration web application. User registration web site becomes your front-end and database becomes your back-end.

Lets take new user registration test case.

Test case will look like this:

Title: New user details submitted to database

Description: Verify that new user registration details are submitted into database upon clicking on [submit] button on the front-end.

Pre-condition / pre-requisite: [Submit] button is functional. All fields in the registration form should have been tested and work as expected.

1. Open xyz application (xyz being name of the application)
2. Click 'register' link
3. Enter data into all the mandatory fields
4. Take a screenshot of the user details (using windows snipping tool)
5. Click [submit] button
6. Open database client
7. Run the following query: 9let's say user name was alpha beta)

Select * from ABC where user_name like 'alpha %'

8. Verify that 'alpha beta' user details are displayed in database
9. Verify that user details in database match with the entered details (on front-end)

End of test

Expected Result: New user registration details flow correctly into the database

Something like that. Pardon my grammar and sentences, in hurry to leave for home...

So you will fill up a registration form and click submit to submit the user details to database.
Then you open a session in database by opening the database client. Run the select statement you wrote in the testcase and compare the data on front end with the details in database.

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.


Related Answered Questions


Related Open Questions