|
When you generate functional tests, BladeSmith creates a set of files that include shell scripts and SQL scripts for testing opaque data type support routines, user-defined routines, and cast support functions. By default, these files are created in the functest subdirectory of the directory containing the BladeSmith project file.
Functional tests are generated only for the DataBlade module objects for which you enter test data in your BladeSmith project. See Adding Functional Test Data for information about entering test data.
Functional testing is typically an iterative process, repeated many times until the code passes all the tests. The testing process has the following general steps:
Functional tests include SQL scripts and shell scripts that execute the SQL scripts and determine the results. The shell scripts build test tables in a database, run the SQL test scripts, and then drop the test tables from the database.
You can create custom shell scripts to run additional tests or initialization scripts. The generated scripts include calls to your custom scripts.
Shell scripts execute SQL scripts using DB-Access. The results from the SQL statements are saved in .log files. When you first run functional tests, you must inspect the .log files and, if the results are correct, use the shell scripts to copy them to .req files.
When you execute functional tests after saving .req files, the shell script uses the UNIX diff command to compare the .log files to the .req files. The script prints the following messages:
Important: There are minor formatting differences between the UNIX and Windows NT versions of DB-Access that can cause tests to indicate failure incorrectly.
The functional test directory, functest, includes the following subdirectories:
The functest directory contains a master shell script, main.sh, for executing all of the functional tests generated for the DataBlade module. Each subdirectory in the udr, opaque, and cast directories also contains a main.sh script to execute only the functional tests in that subdirectory.
The subdirectories in the udr, opaque, and cast directories contain various SQL scripts. Each subdirectory has a setup.sql script and a cleanup.sql script. The setup.sql script creates test tables and initializes them with test data. The cleanup.sql script drops all of the test tables from the database.
BladeSmith creates the following SQL test scripts for the object being tested:
A script is generated only when the support routines it tests are defined.
You can add other tests or initialization scripts to your test suite by adding your own scripts in the subdirectories of the functest directory and editing the sample user.sh shell script that BladeSmith generates. For example, you can add SQL scripts to create a test database, create special test tables in it, and execute custom tests against those tables.
To execute functional scripts, use the main.sh script. Execute a command in all test directories by executing the main.sh command in the top-level test directory. You can execute tests for a specific DataBlade module object by executing main.sh in that object's test directory.
The first time you execute the tests, initialize the reference files. See Initializing Reference Files for instructions.
The TESTDB environment variable must be set to the name of the test database.
The main.sh script is a Bourne shell script that accepts one of five possible command line parameters, as described in the following table.
The first time you run tests, execute the "build" and "run" targets, as follows:
These two steps prepare the database, run the test scripts, and generate .log files. The results of all tests are unknown (no reference file).
Check the results in each .log file to determine if the test returned the correct result. The expected result (which was entered with the test data in BladeSmith) is shown in a comment.
If the results are incorrect, you might need to fix the DataBlade module C code. In other cases, the test data can be incorrect.
When the tests return correct results, create reference files by executing the "save" target, as follows:
After reference files have been saved, use the "all" shortcut target to build and run the tests and clean up the database and test directory.