Beruflich Dokumente
Kultur Dokumente
Contents
DATA BASE TESTING...................................................................................................................................... 2 Database Testing brief .............................................................................................................................. 3 Why Database or back end testing is so important .............................................................................. 3 Differences between back end testing and front end testing .............................................................. 3 Back end test methodology .................................................................................................................. 3 Structural testing: ................................................................................................................................. 3 Functional testing: ................................................................................................................................ 3 Boundary testing: .................................................................................................................................. 3 Stress testing: ........................................................................................................................................ 4 Test a Database via a front end ............................................................................................................ 4 Entry Criteria ............................................................................................................................................. 4 Test Objects .............................................................................................................................................. 4 Tasks.......................................................................................................................................................... 5 Test Environment Preparation .............................................................................................................. 5 Test a Table ........................................................................................................................................... 5 Test Stored Procedure .......................................................................................................................... 6 Test Triggers .......................................................................................................................................... 6 Automation ........................................................................................................................................... 7 Roles & Responsibilities ............................................................................................................................ 7 Deliverables............................................................................................................................................... 8 Exit Criteria................................................................................................................................................ 8 Appendix ................................................................................................................................................... 7 SQL Queries most used in DB Testing ................................................................................................... 8 Common defects in SQL databases ....................................................................................................... 9 Administration issues for database testing ........................................................................................ 10 Tools .................................................................................................................................................... 10 References .............................................................................................................................................. 11
DB Testing
Page 1
DB Testing
Page 2
DB Testing
Page 3
Stress testing: It involves subjecting a database to heavy loads. For incidence, many users heavily access the same table that has a large number of records. To simulate this situation, we need to start as many machines as possible and run the tests over and over. Test a Database via a front end Sometimes back end bugs can be found by front end testing, try to do the following things while testing a backend via front-end Make queries from a front end and issue the searches (It hits SELECT statements or query procedures in a back end) Pick up an existing record, change values in some fields and save the record. (It involves UPDATE statement or update stored procedures, update triggers.) Push FILE - NEW menu item or the NEW button in a front end window. Fill in information and save the record. (It involves INSERT statements or insertion stored procedures, deletion triggers.) Pick up an existing record, click on the DELETE or REMOVE button, and confirm the deletion. (It involves DELETE statement or deletion stored procedures, deletion triggers.) Repeat the first three test cases with invalid data and see how the back end handles them.
Entry Criteria
Relational Database Design fundamentals SQL fundamentals RDBMS administration knowledge Automation Scripting knowledge
Test Objects
Test objects that should be covered in database. Schema Stored Procedures Triggers
Trigger tests
DB Testing Page 4
Tasks
Test Environment Preparation Accessing Permissions
In Progress
Test a Table Verify Table name Verify Column names Verify Column types Verify Column allows NULL or not Verify Default definitions Verify Access privileges are granted to correct groups Verify Primary Key Verify Candidate Keys Verify Foreign Keys
DB Testing
Page 5
Individual procedure tests Verify the following things and compare them with design specification Whether a stored procedure is installed in a database Stored procedure name Parameter names, parameter types and the number of parameters Outputs: when output is zero (zero row affected) when some records are extracted Output contains many records What a stored procedure is supposed to do What a stored procedure is not supposed to do Write simple queries to see if a stored procedure populates right data Parameters: Check parameters if they are required. Call stored procedures with valid data Call procedures with boundary data Make each parameter invalid a time and run a procedure Return values: Whether a stored procedure returns values When a failure occurs, nonzero must be returned. Error messages: Make stored procedure fail and cause every error message to occur at least once Find out any exception that doesnt have a predefined error message Others: Whether a stored procedure grants correct access privilege to a group/user See if a stored procedure hits any trigger error, index error, and rule error Look into a procedure code and make sure major branches are test covered. Integration tests of procedures Group related stored procedures together. Call them in particular order If there are many sequences to call a group of procedures, find out equivalent classes and run tests to cover every class. Make invalid calling sequence and run a group of stored procedures. Design several test sequences in which end users are likely to do business and do stress tests Test Triggers Updating triggers Verify the following things and compare them with design specification Make sure trigger name spelling is correct See if a trigger is generated for a specific table column Triggers update validation Update a record with a valid data Update a record, a trigger prevents, with invalid data and cover every trigger error Update a record when it is still referenced by a row in other table Make sure rolling back transactions when a failure occurs Find out any case in which a trigger is not supposed to roll back transactions DB Testing Page 6
Inserting triggers Verify the following things and compare them with design specification Make sure trigger name spelling See if a trigger is generated for a specific table column Triggers insertion validation Insert a record with a valid data Insert a record, a trigger prevents, with invalid data and cover every trigger error Try to insert a record that already exists in a table Make sure rolling back transactions when an insertion failure occurs Find out any case in which a trigger should roll back transactions Find out any failure in which a trigger should not roll back transactions Conflicts between a trigger and a stored procedure/rules (i.e. a column allows NULL while a trigger doesnt) Deleting triggers Verify the following things and compare them with design specification Make sure trigger name spelling See if a trigger is generated for a specific table column Triggers deletion validation Delete a record Delete a record when it is still referenced by a row in other table Every trigger error Try to delete a record that does not exists in a table Make sure rolling back transactions when a deletion fails Find out any case in which a trigger should roll back transactions Find out any failure in which a trigger should not roll back transactions Conflicts between a trigger and a stored procedure/rules (i.e. a column allows NULL while a trigger doesnt)
Automation
In Progress
DB Testing
Page 7
Deliverables
Test Environment details DB Test Plan Test Scenarios & Cases Test Results
Example: SELECT 'Franks''s Oracle site' FROM DUAL; SELECT 'A ''quoted'' word.' FROM DUAL; SELECT 'A ''''double quoted'''' word.' FROM DUAL; How does one eliminate duplicates rows from a table? Choose one of the following queries to identify or remove duplicate rows from a table leaving only unique records in the table: Method 1: SQL> DELETE FROM table_name A WHERE ROWID > (SELECT min (rowid) FROM table_name B WHERE A.key_values = B.key_values); Method 2: SQL> create table table_name2 as select distinct * from table_name1; SQL> drop table_name1; SQL> rename table_name2 to table_name1; SQL> -- Remember to recreate all indexes, constraints, triggers, etc on table... Method 3: SQL> delete from my_table t1 SQL> where exists (select 'x' from my_table t2 where t2.key_value1 = t1.key_value1 and t2.key_value2 = t1.key_value2 and t2.rowid > t1.rowid); Common defects in SQL databases Reasonableness of the data - If you regularly receive a certain amount of sales, an influx of rows added to critical system tables well over the norm should raise a red flag. So should lack of records on days that should have generated a regular amount of sales. Data corruption - Data should be regularly QAd to find garbage data within columns Redundant data - Hidden duplicate records (same customer added twice with different primary keys). How many of us get multiple copies of newsletters? This annoys and loses customers.
Evidence of hacking - Plan test cases to uncover multiple similar records added on the same day. Inconsistent data - Data records added to the same database through multiple applications can add inconsistent data. For example, if the customer application adds data with formatting applied to columns such as phone numbers and e-mail, but the Admin application to the same data does not, then the data can become inconsistent and not match properly with reports. A worse example is
DB Testing
Page 9
required fields set at the customer application not being set at the Admin application leaving orphan records or unintelligible data. Evidence of hacking o SQL Injection attacks Malicious attempts to corrupt data Serious attempts to reprise data for theft or embezzlement Multiple users added o Denial of service attempts Overloaded tables Administration issues for database testing Server-side management issues: Tools
Category Description Examples Testing Tools simulate high usage tools for loads on your database, load testing enabling you to determine whether your system's architecture will stand up to your true production needs. AnyDbTest DBFit DBUnit NDbUnit OUnit for Oracle (being replaced soon by Qute) SQLUnit TSQLUnit (for testing T-SQL in MS SQL Server) Visual Studio Team Edition for Database Professionals includes testing capabilities XTUnit Empirix Mercury Interactive RadView Rational Suite Test Studio Web Performance Unit testing Tools which enable you to tools regression test your database.
Defective Installations and Configurations Database Security Issues Disaster Recovery Issues Creating a Test Server Distributed Data Issues Replication Issues Reliability and Capacity planning
DB Testing
Page 10
Developers need test data against which to validate their systems. Test data generators can be particularly useful when you need large amounts of data, perhaps for stress and load testing.
References
http://msdn.microsoft.com/en-US/library/bb381703(v=VS.80).aspx
DB Testing
Page 11