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

  1. 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 2.00.06-201905141203
    # =============================================================================
    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 a MAIN block and a function called play_0 is generated. The following describes the MAIN code statements:
    • The FGL class ggc is imported.
    • The call to the ggc.setApplicationName gets the application name to start.
    • The call to the ggc.parseOptions method initializes the parse options that perform the following operations:
      1. Parse and validate command line options
      2. Initialize the scenario configuration
      3. Connect to the BDL scenario server
      4. 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.
  2. To the play_0 function add code to test an application.
    # =============================================================================
    # Generated using Genero Ghost Client 2.00.06-201905141203
    # =============================================================================
    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
    In this simple test scenario the window name is retrieved from the client and the action cancel is triggered. In between these tests, there is a request for the client to "sleep" for the specified delay of 100 milliseconds.