What are the typical steps involved in Testing Databases What are the typical steps involved in Testing Databases Database testing primarily involves two key activities like: Database testing primarily involves two key activities like: A) Organising Sandboxes
A) Organising Sandboxes B) Developing Test Cases B) Developing Test Cases
Now let us discuss these two key activities in
Now let us discuss these two key activities in detaildetail
A) Key Activity -
A) Key Activity - 1: Organising Sandboxes1: Organising Sandboxes::Database testing involves the need of a copy of Database testing involves the need of a copy of databasesdatabases which are called sandboxes. These sandboxes are of
which are called sandboxes. These sandboxes are of following three typesfollowing three types 1)
1) Functionality Sandbox:Functionality Sandbox:In this we check In this we check the new functionality of database and refactor the existingthe new functionality of database and refactor the existing functionality. Then we pass the tested sandbox to the next stage, which is integrated sandbox.
functionality. Then we pass the tested sandbox to the next stage, which is integrated sandbox. 2) Integrated Sandbox:
2) Integrated Sandbox: In this we In this we integrate all the sandboxes and then test the system.integrate all the sandboxes and then test the system. 3) QA sandbox:
3) QA sandbox:After the system is tested, sandboxes are sent for acceptance testing. This will ensure theAfter the system is tested, sandboxes are sent for acceptance testing. This will ensure the quality of the database.
quality of the database.
B) Key Activity -
B) Key Activity - 2: Development of test cases:2: Development of test cases:The step by step procedure for the development of testThe step by step procedure for the development of test cases is as under:
cases is as under:
Step - 1:
Step - 1:Setting up of the Setting up of the test cases:test cases:Set up the database to a known state.Set up the database to a known state. The sources of test data are
The sources of test data are 1) External test data.
1) External test data. 2) Test scripts.
2) Test scripts.
3) Test data with known values. 3) Test data with known values.
4) Real world data. 4) Real world data.
Step - 2: Running the test cases :
Step - 2: Running the test cases : The test cases are then run. The running of the database test cases isThe test cases are then run. The running of the database test cases is analogous to usual development testing.
analogous to usual development testing.
Traditional Approach of Test Case Execution: Traditional Approach of Test Case Execution:
Test cases are executed on the browser side. Inputs are entered on web-input forms and data i submitted to Test cases are executed on the browser side. Inputs are entered on web-input forms and data i submitted to the back-end database via the web browser interface. The results sent back to
the back-end database via the web browser interface. The results sent back to the browser are then validatedthe browser are then validated against expected values.
against expected values.
Advantages of Traditional Approach:
Advantages of Traditional Approach: It is It is simple and no programming skill is required. It simple and no programming skill is required. It not only addressesnot only addresses thi functionality of stored procedures, rules, triggers and data integrity but
thi functionality of stored procedures, rules, triggers and data integrity but also the functionality of applicationalso the functionality of application as a whole.
as a whole.
Disadvantages of Traditional Approach: Disadvantages of Traditional Approach: 1) Sometimes the results sent to
1) Sometimes the results sent to the browser after test case the browser after test case execution do no necessarily indicate that the dataexecution do no necessarily indicate that the data itself is properly written to a record in the t
itself is properly written to a record in the t able.able. 2) When erroneous results are sent back
2) When erroneous results are sent back to the browser after to the browser after the execution of test cases, it the execution of test cases, it doesn'tdoesn't necessarily mean that the error is a database error.
necessarily mean that the error is a database error. 3) A crucial dange
3) A crucial danger with database testing and with regression testing in r with database testing and with regression testing in specific is coupling between tests. If specific is coupling between tests. If we put the database in to
we put the database in to a known state, run several tests a known state, run several tests against that known states, before setting it, thenagainst that known states, before setting it, then those tests are potentially coupled to one another.
those tests are potentially coupled to one another.
Advanced Approach of Test Case Execution: Advanced Approach of Test Case Execution:
First of all we need to do a schematic preparation for Database Testing, which involves: First of all we need to do a schematic preparation for Database Testing, which involves: Generate a list of database tables, stored procedures, triggers, defaults, rules and so
Generate a list of database tables, stored procedures, triggers, defaults, rules and so on. This will help us on. This will help us toto have a good handle on the scope of testing required for database testing.
have a good handle on the scope of testing required for database testing. Thereafter we can follow the
Thereafter we can follow the following points:following points:
1. Generate data schemata for tables. Analyzing the schema will help us determine the following: 1. Generate data schemata for tables. Analyzing the schema will help us determine the following: # Can a certain field value be Null?
# Can a certain field value be Null? # What are the
# What are the allowed or disallowed values?allowed or disallowed values? # What are the
# What are the constraints?constraints?
# Is the value dependent upon values in another table? # Is the value dependent upon values in another table? # Will the values of this field be in the
# Will the values of this field be in the look-up table?look-up table? # What are user defined data types?
# What are user defined data types? # What are primary
# What are primary key and foreign key relationships among tables?key and foreign key relationships among tables?
2. At a high level, analyze how the stored procedures, triggers, defaults and rules work. This will help 2. At a high level, analyze how the stored procedures, triggers, defaults and rules work. This will help us determine the following:
us determine the following:
# What is the primary function of each stored procedure and trigger? Does it read data and produce outputs, # What is the primary function of each stored procedure and trigger? Does it read data and produce outputs, write data or both?
write data or both?
# What are the accepted parameters? # What are the accepted parameters?
# What are the
# What are the return values?return values? # When is the
# When is the stored procedure called and by whom?stored procedure called and by whom? # When is a trigger fired?
# When is a trigger fired?
3. Determine what the configuration management process is. That is how the new tables, stored procedures, 3. Determine what the configuration management process is. That is how the new tables, stored procedures, triggers and such are
triggers and such are integrated.integrated.
Step - 3:
Step - 3: Checking the results:Checking the results:Actual database test results and expected database test results areActual database test results and expected database test results are compared in this step as described in the following example.
compared in this step as described in the following example.
CREATE FUNCTION f_is leapyear (@ ai_year small int) CREATE FUNCTION f_is leapyear (@ ai_year small int) RETURNS small int
RETURNS small int AS
AS BEGIN BEGIN
-if year is illegal (null or -ve ), return -1 -if year is illegal (null or -ve ), return -1 IF (@ ai_year IS NULL) or
IF (@ ai_year IS NULL) or (@ ai_year <=0) RETURN -1 (@ ai_year <=0) RETURN -1 IF (((@ ai_year % )
IF (((@ ai_year % ) = 0) AND= 0) AND ((ai_year % 100) <> 0)) OR ((ai_year % 100) <> 0)) OR ((ai_year % 400) = 0) ((ai_year % 400) = 0) R REETTUURRN N 11 -l-leeaap p yyeeaar r R REETTUURRN N 00 - - NNoot t a a lleeaap p yyeeaar r END END
Following test cases are derived for the above piece of code: Following test cases are derived for the above piece of code:
T Teesstt__iidd YYeeaar r ((YYeeaar r to Test) to Test) Expected Expected Result Result Observed Observed Result Result Match Match 1 1 --11 --11 --11 YYeess 2 2 --440000 --11 --11 YYeess 3 3 110000 00 00 YYeess 4 4 11000000 00 00 YYeess 5 5 11880000 00 00 YYeess 6 6 11990000 00 00 YYeess 7 7 22001100 00 00 YYeess 8 8 440000 11 11 YYeess 9 9 11660000 11 11 YYeess 10 10 22000000 11 11 YYeess 1 111 22440000 11 11 YYeess 12 12 44 11 11 YYeess 13 13 11220044 11 11 YYeess 14 14 11999966 11 11 YYeess 15 15 22000044 11 11 YYeess Article By: Article By: http://www.softwaretestinggenius.com http://www.softwaretestinggenius.com
A Storehouse of Complete Knowledge on Software Testing & QA under one Roof A Storehouse of Complete Knowledge on Software Testing & QA under one Roof