Database Testing Checklist
Database Testing Checklist
Generally, database operations involve the following activities: First-time activities (eg, the setup process): 1. It should Connect to the database server. 2. It should be able to Create new databases. 3. It should be able to Create tables, defaults, and rules; populate default data. 4. It should be able to Compile stored procedures and triggers. After the setup process has completed successfully, using the database consists of the following activities: Connect to database. Execute SQL statements, stored procedures, and triggers. Disconnect from the database. The common types of errors uncovered in database activities include: Failures in connecting to the database. Several potential problems that cause this type of failure include the following: Invalid user name, password, or both. User has inadequate privileges required for certain data activities, such as creating tables and stored procedures. Invalid or wrong DSN (The data source name (DSN) used in Microsoft ODBC technology is a reference to the collection of information used by the ODBC manager to connect an application to a particular ODBC database. A DSN can be stored in a file or a file DSN. A DSN can also be stored in a User/System registry or a machine DSN). see examples in following Figures:
Figure 14.25 Invalid ID or password error message. Failure to connect to the server that has the needed file DSN. Several potential problems that can cause failures in creating databases, tables, defaults, rules, stored procedures, and triggers, as well as failures in populating default data, include: Failure to create files. Inadequate storage required for creating databases and tables. Resource contention keeps one or more stored procedures or tables from being created. Some of the common errors in the instructions (stored procedures, triggers, etc.) include: The database is configured to be case-sensitive, but the code is not. Using reserved keywords in the SQL statement. For example: SELECT user FROM mytable. Since user is the reserved keyword, this can cause a problem. NULL is passed to a record field that does not allow NULL. Mishandling single quote () in a string field. See Figure 14.15 for an example.
Figure 14.15 An SQL syntax error. Mishandling comma (,) in an integer field. See Figure 14.18 for an example.
Figure 14.18 Mishandling a comma (,). Mishandling wrong data type. For example, if a field such as employee_salary in a record expects an integer, but receives $500 instead, it will complain because 500 is an integer but $500 is not. See Figure below for more examples:
Figure 14.19 Wrong data type. A value is too large for the size of the field. A string is too long for the size of the field. See Figure 14.17 for an example.
Figure 14.17 The string is too long. Time-out: The time it takes the database to complete executing the procedure is longer than the time-out value set in the script (e.g., ASP script). Invalid or misspelled field or column, table, or view name. Undefined field, table, or view name. Invalid or misspelled stored procedure name. Calling the wrong stored procedure. Missing keyword. An example would be the code written as follows: ... create view student_view select * from student_tbl ... instead of ... create view student_view as select * from student_tbl ... Notice that as was omitted. Missing left parenthesis. For example: INSERT INTO staff id, city, state, salary, name) VALUES(13, Phoenix, AZ, 33000, Bill) Missing right parenthesis. For example: INSERT INTO staff (id, city, state, salary, name VALUES(13, Phoenix, AZ, 33000, Bill)
Missing comma. For example: ... INSERT INTO staff (id, city, state, salary, name) VALUES(13, Phoenix, AZ, 33000 Bill) Missing keyword. Misspelled keyword. Missing opening or closing parenthesis before the keyword. Certain functions are disallowed, to be used with group by. For example, the following statement can cause error: ... group by count (last_name), first_name, age ... Missing arguments for a function. Missing values. For example: ... /* Create stored procedure that accepts parameters for inserting records */ CREATE PROCEDURE add_staff (@P1 INT, @P2 CHAR(20), @P3 CHAR(2), @P4 INT, @P5 CHAR(20)) AS INSERT INTO staff VALUES (@P1, @P2, @P3, @P4, @P5) /* Inserting 3 records with created stored procedure */ add_staff 13, Phoenix, AZ, Bill ... Insufficient privilege to grant permissions. Invisible invalid characters such as ESC. Errors in implementing COMMIT TRANSACTION and ROLLBACK TRANSACTION. The COMMIT TRANSACTION statement saves all work started since the beginning of the transaction. The ROLLBACK TRANSACTION statement cancels all the work done within the transaction. COMMIT and ROLLBACK errors cause partial data to be undesirably saved.
Testing Triggers
Triggers are executed when certain events such as INSERT, DELETE, and UPDATE are applied to table data. A trigger can call itself recursively or call other stored procedures. The testing objectives should include the following: Does the stored procedure or trigger meet the design objectives? For each conditional statement, does the handling of the condition execute properly? For each predefined input, does the procedure produce correctly expected outputs? Have all input cases identified in the equivalence class and boundary condition partitioning process been executed (either by walk-through, executing the stored procedure, or calling the stored procedure from other procedures)? For each possible error condition, does the procedure detect such condition? Is the handling of each detected error reasonable?
No. of arguments passed Data Type of each of the arguments being passed Order of the arguments being passed Return value Data type of the return value Based on these we can write both positive & negative test cases, consider a simple eg of a stored procedure taking 2 numbers as input and returning the sum of the 2 numbers Security Tables can only be accessible through Stored Procedures. Performance of SP (it should be fast).
Figure 14.21 Table design view. 2. At a high level, analyze how the stored procedures, triggers, defaults, and rules work. This will help to determine: What is the primary function of each stored procedure and trigger? Does it read data and produce outputs, write data, or both? Pay particular attention to procedures that have keywords such as INSERT, DELETE, and UPDATE, because they might have effects on data integrity. What are the accepted parameters? What are the returned values? When is a stored procedure called, and by whom? When is a trigger fired? 3. Determine what the configuration management process is? That is how the new tables, stored procedures, triggers, and such are integrated in each build. In other words, Determine how stored procedures are added, removed, or updated? This will help to determine the effects on testing.