Writing an Auto Test
Writing an auto test is like writing any other ODBC application. You must write code to allocate and free handles, connect to and disconnect from data sources, and access data. As a starting point, you can use custom.c or quiktest.c in the \Samples\Odbc\Quiktest directory.
Note An auto test does not have to manage handles or connections if it uses the ODBC Test Handles test source.
An auto test contains one or more test cases, each of which tests some specific functionality. For example, an auto test for SQLAllocStmt might contain two test cases, one to call SQLAllocStmt with all combinations of valid and invalid arguments and one to call SQLAllocStmt repeatedly until the driver runs out of statement handles.
The QTBUILD program shipped with the SDK requires specified names for the source files for an auto-test DLL.
The auto test must export the following functions, which are called by ODBC Test:
-
AutoTestName. This function returns the name of the auto test and the number of test cases it includes. ODBC Test displays the auto test name in the Manage Auto Tests, Manage Test Groups, and Run Auto Tests dialog boxes.
-
AutoTestDesc. This function returns the name and description of a specific test case. ODBC Test displays the test case name and description in the Run Auto Tests dialog box.
-
AutoTestFunc. This function invokes the auto test for a specific test source. Information about the test source and a bit array of the test cases to execute are passed to the auto test in a structure created by ODBC Test.
An auto test can call the following two functions in gtrtst32.dll:
-
szLogPrintf. An auto test calls this function to log test results and other information to the screen and the log file.
-
szMessageBox. An auto test calls this function to display a message box. This function encapsulates the MessageBox function in the Windows API. Unlike the MessageBox function, it accepts a format string and a list of arguments with which it constructs a string to pass to MessageBox.