Automated Testing of Otk Applications

OTK supports automatic GUI-testing with an ability to capture keyboard and mouse input into a test-stimulus file. The stimulus file can then be applied in future regression tests, as if you were manually operating the GUI.

To build a test-stimulus file, invoke your OTK application with the -otk_test_capture option.
Example:       ./your_app   -otk_test_capture

Then interact with the GUI to perform the tests that you would like to repeat in the future. Your keyboard and mouse interactions will be saved to a file called otk_test_capture.xml, which is completed when you exit the GUI. It is an XML file that is readable and can be edited, or even generated by alternate means.

To apply your previously captured stimulus file to a new session, invoke your OTK application with the -otk_test_play option.
Example:       ./your_app   -otk_test_play

You will then observe the GUI responding to your previously captured interactions.



Advanced Techniques & Information

Your application can trigger the beginning and ending of recording test-simulus, with the following two functions:

Otk_Start_Capturing_TestFile();
Otk_Close_TestFile();

Likewise, your application can consume test-input from an arbitrary stimulus file, with the following function:

Otk_Apply_Test_Stimuli( char *filename );

The format of stimulus files is:

Mouse Click:

<mouse_click x="" y="" state=""/>
The x and y position of the mouse click is recorded in OTK percent coordinates of the application's window, also called outer-window. Where, (0.0, 0.0) is the upper left corener of the OTK outer-window, and (100.0, 100.0) is the lower-right corener of the OTK outer-window. The state value is zero when the mouse button is pressed down, and one when the mouse buttin is up (released).

Mouse Movements:

<mouse_move x="" y="" dx="" dy=""/>
The x/y values are like above. The dx and dy values are the difference from the last mouse click, and are relevent during mouse-drag operations.

Key-board events:

<key press=""/>
<key release=""/>
The value of the key-press or release event is the ascii value of the key-pressed.







Back to main page

SourceForge.net Logo