Write a Genero BDL test
To write a test in Genero BDL, one file may contain the function that manages the session and the function that runs tests.
Steps
-
Begin by running the Genero Ghost Client ggcgen tool to create
a skeleton application.
ggcgen bdl --skeleton myapp_tests
The myapp_tests.4gl file is created as shown:# ============================================================================= # Generated using Genero Ghost Client 5.00.02-202407171025 # ============================================================================= IMPORT FGL ggc MAIN CALL ggc.setApplicationName("") CALL ggc.parseOptions() # Register scenario functions CALL ggc.registerScenario(FUNCTION play_0) # Start execution CALL ggc.play() EXIT PROGRAM 0 END MAIN # Scenario myapp_tests id : 0 PRIVATE FUNCTION play_0() END FUNCTION
In the sample code aMAIN
block and a function calledplay_0
is generated. The following describes theMAIN
code statements:- The FGL class
ggc
is imported. - The call to the
ggc.setApplicationName
method gets the application name to start. - The call to the
ggc.parseOptions
method initializes the parse options that perform the following operations:- Parse and validate command line options
- Initialize the scenario configuration
- Connect to the BDL scenario server
- Bootstrap the scenario
- The call to the
ggc.registerScenario(FUNCTION play_0)
method registers a scenario function for a test with the id of 0. A test may register multiple test scenarios. They run in the sequence registered. - The call to the
ggc.play()
method starts the test of the registered scenarios.
- The FGL class
-
To the
play_0
function add code to test an application.# ============================================================================= # Generated using Genero Ghost Client 5.00.02-202407171025 # ============================================================================= IMPORT FGL ggc MAIN CALL ggc.setApplicationName("") CALL ggc.parseOptions() # Register scenario functions CALL ggc.registerScenario(FUNCTION play_0) # Start execution CALL ggc.play() EXIT PROGRAM 0 END MAIN # Scenario myapp_tests id : 0 PRIVATE FUNCTION play_0() DEFINE windowTitle STRING # Get window title LET windowTitle = ggc.getWindowTitle() DISPLAY "Window title is: " || windowTitle DISPLAY "Exiting with action 'cancel'" CALL ggc.wait(100) CALL ggc.action("cancel") CALL ggc.end() END FUNCTION
cancel
is triggered. In between these tests, there is a request for the client to "sleep" for the specified delay of 100 milliseconds.