• No results found

Database Testing Checklist

N/A
N/A
Protected

Academic year: 2021

Share "Database Testing Checklist"

Copied!
18
0
0

Loading.... (view fulltext now)

Full text

(1)

Basic Database Testing Checklist

Basic Database Testing Checklist

Generally

Generally, database operations involve the following , database operations involve the following activities:activities: First-time activities (eg, the setup process):

First-time activities (eg, the setup process): 1. It should Connect

1. It should Connect to the database serto the database serverver.. 2. It should be able to Create new databases. 2. It should be able to Create new databases.

3. It should be able to Create tables, defaults, and rules; populate default data. 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.

4. It should be able to Compile stored procedures and triggers. After the setup process has

After the setup process has completed successfullycompleted successfully, using the database consists of the , using the database consists of the followingfollowing activities:

activities:

■■

■■ Connect to database.Connect to database. ■■

■■ Execute SQL statements, stored procedures, and triggers.Execute SQL statements, stored procedures, and triggers. ■■

■■ Disconnect from the database.Disconnect from the database.

The common types of errors uncovered in database activities include: The common types of errors uncovered in database activities include:

■■

■■ Failures in connecting to the database. Several potential problems that cause this Failures in connecting to the database. Several potential problems that cause this type of type of  failure include the following:

failure include the following:

■■

■■ Invalid user name, password, or both.Invalid user name, password, or both. ■■

■■ User has inadequate privileges required for certain data activities, such as creating tables andUser has inadequate privileges required for certain data activities, such as creating tables and stored procedures.

stored procedures.

■■

■■ Invalid or wrong DSN (TheInvalid or wrong DSN (The data source namedata source name (DSN) used in Microsoft ODBC technology is a(DSN) used in Microsoft ODBC technology is a reference to the collection of information used by the ODBC

reference to the collection of information used by the ODBC manager to connect anmanager to connect an

application to a particular ODBC database. A DSN can be stored in a file or a file DSN. A DSN can 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: also be stored in a User/System registry or a machine DSN). see examples in following Figures:

Figure 14.22

(2)
(3)

Figure 14.23 Configuration summary.

(4)
(5)

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 s tring field. See Figure 14.15 for an example.

Figure 14.15 An SQL syntax error.

(6)
(7)

Figure 14.18Mishandling 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:

(8)
(9)

Figure 14.19 Wrong data type.

■■ A value is too large for the size of the field.

(10)
(11)

Figure 14.17The 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 a s 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:

(12)
(13)

■■ 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?

Testing Stored Procedures

■■ Every Stored Procedure is to be tested s eparately for its functionality (Based on se parate

functions it performs)Stored Procedures need to be broken up into Action items based on Functions and then Each action item needs to be tested separately as the results of complete stored procedure

■■ Execution may differ from the results obtained by partial execution. This also helps in validating the modularity of code.

(14)
(15)

 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).

Preparation for Database Testing

To prepare for database testing, generate a list of database tables, stored procedures, triggers, defaults, rules, and so on. This will help to have a good handle on the scope of testing required for database testing. Figure 14.20 illustrates a list of stored procedures in a Microsoft SQL 7.0

database.

1. Generate data schemata for tables. Anal yzing the schema will help to determine:

■■ Can a certain field value be NULL?

■■ What are the allowed or disallowed values?

■■ What are the constraints? (look for any constraints defined in a database) ■■ Is the value dependent upon values in another table?

■■ Will the values of this field be in the lookup table?

■■ What are the user-defined data types?

■■ What are the primary and foreign key relationships among tables?

■■ Are there any Orphan objects? There should not be any Orphan objects.

■■ Is Indexing done for every table? There should exist an index fiel d in every table with

sufficient length defined.

■■ There should not be redundancy in tables.(No duplicate of data)

■■ scalability – it should be able to store the data inserted ■■ performance – it should respond to the queries.

Figure 14.21 shows a screen shot of a table design that lists all the column names, data types, lengths, and so on, of a Microsoft SQL 7.0 database table.

(16)
(17)

Figure 14.21 Table design view.

2. At a high level, analyze how the stored procedures, tr iggers, defaults, and rules work. This will help to determine:

■■ What is the primary function of each s tored procedure and trigger?

Does it read data and produce outputs, write data, or both? Pay particular at tention 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.

(18)

References

Related documents

From a Korean perspective AustranaTs it eleventh largest export market and sixth most important import sour~ While Korea's financial and economIc cnS1S of 1997-98

Comment Editor of the Seattle University Law Review. I would like to thank my family and especial- ly my husband, Tim Burns. I am so grateful for your unwavering support. I would

If you face a battery of tests at the advanced level, including tests of your verbal and abstract reasoning skills, I would recommend that you use the following books published by

Za potrebe istraživanja preuzete su satelitske snimke misija Landsat područja grada Splita s internetske stranice EarthExplorer (URL 1), koja je u nadležnosti Agencije

[EXAMPLEI CARBURETOR ASS'Y.. of consUtu..,1

Tiamat /τιαμάτ/ Μία από τις δύο αρχέγονες θεότητες του βαβυλωνιακού πανθέου, προσωποποίηση του χάους και του αλμυρού νερού και σύζυγος του θεού

The research questions were designed to investigate the relationship between intention to adopt palm vein authentication technology and perceived usefulness, complexity,

Given the low star formation rate in these low-metallicity dSph galaxies and the extremely low fraction of the neutron-capture elements even at solar metallicity, a wide range in