| Testing of Applications that Work with Databases |
|
|
|
| Thursday, 16 December 2010 14:54 |
|
Databases are an essential part of the modern software such as client-server software or web-applications. Our team has some experience in testing of applications that work with databases. The purpose of this article is to sum up the gathered experience and to share it with those who faced the similar task for the first time. The article is a small manual with practical ideas that can be useful while writing the test plan for your application. Test cases are gathered with no relation to some definite type of application or DBMS (Database Management System); that is why they do not claim to be taken “as is”. After reading this article, you will be able to adapt them to your concrete product.
Written by: Applications that Work with Databases Applications that Work with DatabasesAs a rule, applications that work with databases are multilevel: client and server parts, and the database itself. The database can be an instance of any existing DBMS on the modern market: MS Access, SQL Server, Oracle, Mysql, Firebird. An application can represent a program code written in one of modern programming languages, such as C, C++, C#, Java for a client-server application and in the script language, such as JavaScript, PHP, Perl, etc. for a web-application. Installation TestingThe acquaintance of a user with your product begins with the installation, that is why it is important to pay special attention to it.
Connection type: local. The following test cases appear:
Connection type: network.
Here are also some test cases that can be useful for the majority of applications:
Functional TestingThere are three main operations with data: adding, editing, and deleting. We check the correct performance of these operations by the fourth one - selection. As the article concerns the blackbox testing, the test cases are written with an assumption of work through the user interface. Let’s make one more assumption – the tested application has definite entry fields for adding data to the database tables. In this case, the entry fields will be the instrument for the check of the correct interaction of the application and the database. Testing of applications that work with the database using entry fields of the client interface is a classic example of the data-driven testing. We will examine only three main test scenarios for each of three operations with data. Then, we will suggest only input data and the expected result for it. Adding data
Expected result: Selected data is identical to the entered data. Editing data
Expected result: Selected data is identical to the edited data. Here, we shouldn’t also forget about two additional negative test cases: Changing data to the incorrect one Changing data so that it fully duplicates the existing record in the database Expected result: In both cases, the correct system response will be to warn the user about the error and do not save the incorrect input in the database table. Deleting data
Expected result: Deleted data is absent by selection. Here, the tests on database cleanup are also worth mentioning:
Input dataText fields
Expected result: A record with the entered text in the corresponding field appeared in the corresponding database table.
Expected result: numeric characters should be available for input in the text field. The just entered value is stored in the corresponding table of database. The value can be checked by the corresponding query.
Expected result: In the database table, the record is not cut before the space character if there are significant symbols after it.
Expected result: Space characters are cut at the beginning of the string till the first significant symbol (the same is for the space characters at the end of the string)
Expected result: The application should return the informative error message and warn the user that data is duplicated.
Expected result: The application should not give the user an opportunity to enter more symbols than it is specified for this field in specification. The user can be warned about it by the beep sound, warning GUI marker, or in any other way.
Expected result: The string with the acceptable symbol appears in the database table.
Expected result: The entered string is stored in the database correctly.
Expected result: Non-roman symbols are stored in the database in the form they were entered in the field. It can be checked by the corresponding query. The test examples given below represent a specific input; expected result for each of them is that the entered data must be stored as a string value in the database and must be available by the selection:
Integer-valued fields
Expected result: Integer value is stored in the database correctly and can be selected by the corresponding query; after the selection it is represented as the integer number.
Expected result: Both boundary and border values must be stored and processed as any other value from the range.
Expected result: The user should be informed that the value cannot be added to the database, or such input should be disabled.
Expected result: а) Input of non-number symbols must be blocked; b) An informative error message and the offer to re-fill the field must be returned
Expected result: If the field is not a key one according to the program logic, such input must be acceptable. The corresponding field is empty in the database table.
Expected result: The space character should be considered as an empty field. The following set of test examples is a negative one. The expected result is an error message and absence of a new record in the database tables.
Fields with fractional number values
Expected result: The numeric value should be brought to the format with floating point. The result of the corresponding query must be “1.0”
Expected result: Data must be stored and the result of the corresponding query must be “1.0”.
Control Panel -> Region and Language -> Numbers -> Additional settings ->Decimal symbol Expected result: The entered value with a new delimiter is processed by the database correctly Negative test cases:
Expected result (7-8): There should be input verification applied, and as the result, user should be informed that the data he entered are invalid and the insertion to the table of database will not be performed. Date fields Expected result for all positive cases: the corresponding query result must contain the just entered value; for all negative test cases: the invalid input must be processed before adding the value(s) to the table of database.
In case, when two dates define the time interval:
Address fields Expected result for the test cases 1-7: The result of the corresponding queries must be equal to the data entered for adding to the table of database.
The test cases given below are negative, and the data proposed in them must not be added to the database.
User passwords If the application supposes authorization, it surely supports the creation of user passwords. Here, it is worth mentioning one important test.
Expected result: The password is encrypted and stored in the encrypted form. You should open the table of database where the user passwords are stored and make sure that they are stored in the unreadable form. Stress TestingIn this part of the article, we will represent some tests that will help you to check the recover after failure functionality of your software. Network Supposing, the application and the database are installed on the different network nodes. In this case, it is worth checking how the application behaves if the connection is lost during the interaction of the application and the database. Let’s examine the following test:
Expected result: The user must be warned of the reason of the system failure with the message concerning the absence of network connection. After the network problem is solved, the application continues interaction with the database correctly. It depends on the database system architecture, if the data or its part is added to the table. Insertion can be performed as the atomic transaction and as a sequence of smaller transactions. In the first case, the insertion will not be performed at all, in the second case some part of data can be successfully added to the database. The connection failure can be caused in the following ways (each of the proposed methods should be checked on machine with installed application as well as on the machine with the database):
Port One more reason to check the system recovery after the failure is the network port, through which the interaction of your application and the database is performed via network. The simplest test is to create a rule for Windows Firewall that will block the incoming and outgoing connection through the specified port. The application should return the maximum informative message about the problem that limits the possibility to interact with the database. After the rule deletion, connection should be restored and the interaction between the database and application should be continued without difficulties. Database service One more possibility to check the system stability is to terminate the database service during the system work. Situation is similar to the test with network.
Expected result: Transaction is terminated. Message about the failure is returned to the user. After the service start, the system work resumes. ConclusionIn this article, I try to share all that experience that our team has gained working on various projects concerning tasting of the applications based on the client-server architecture. The main concept that is valid for all positive functional test cases is the following: the data, which are inserted into the tables of database, can be checked by means of the corresponding queries. The data returned by the query and data entered in the insertion form must be equal. The main concept concerning he negative test cases is that the insertion of the invalid data must be blocked by the system. I hope that using the basic test cases provided in this article you will manage to find the bottle-necks in the tested system easily. |






