Zeos Library Open Source Development Tools

http://zeoslib.sourceforge.net/

Autors: Sergey Merkuriev
Modified: February 28, 2003

SQL Tests Framework

The conguration file


The database directory contain test_config_template.ini file. This file contains list of active sql servers and connection parameters for each server.

Example:
[common]
active=mysql-3.23

[mysql-3.23]
host=localhost
port=3306
database=zeoslib
user=root
password=
extra=

[postgresql-7.23]
host=localhost
port=
database=zeoslib
user=root
password=
extra=
..........


You should copy this template file to test_config.ini and set parameters for your servers.
The section common contain the active property what contains a list of servers, which are running at the moment of testing. All active protocols must be be separated by ';' or ',' simbols. It allows you to run tests multiple times for different servers without changing the source code and recompilation.

The configuration file in the same way contains the sections of settings for connection to database servers. Each section defines adjustment for certained server. The section must have such name either as protocol used in DBC components and this name must be set in sections common in property active. Each section mysql, postgresql contains options such as

The test classes

All test cases are splitted into two major classes: Generic and Specific.
Generic test cases execute all tests for each server, listed in active parameter. They must extends from TZGenericSQLTestCase.

Specific test cases are intended only for selected servers. Specific test case
must extend TZSpecificSQLTestCase. In GetValidProtocols you must define
a list of protocols which can be tested. There is test overload function GetValidProtocols and set list active protocols for test.

Example
function TZTestSpecificSQLTestCase.GetValidProtocols: TStringDynArray;
begin
SetLength(Result, 2);
Result[0] := 'mysql';
Result[1] := 'postgresql';
end;

In runtime TestCase compares this list with a list of protocols from active property and executes only matched protocols.
For testing you must create procedures in published section and set test code into they

Example

TZTestSpecificSQLTestCase = class(TZSpecificSQLTestCase)
protected
function GetValidProtocols: TStringDynArray; override;
published
procedure TestOne;
procedure TestTwo;
procedure TestTree;
end;

Extended functions


The TZGenericSQLTestCase and TZSpecificSQLTestCase contains extendex function for testing variables such as:

Note: Your test unit must contain dbc driver declaration in uses section, because driver manager will nothing know about driver what used in the test. When test case will run test for apropriate protocol from GetValidProtocols and you will call connection and dbc driver will not registered it will raise exception and fail test.
Copyright (c) 1999-2003 Zeos Development Group. All rights reserved.