Quick Start: Customize a template

In this quick start, you will customize a template, and provide the template to the ggcgen command when generating test scenarios.

Before you begin:

The price application in the $GGCDIR/src/quick-start is already compiled, and the log file price_sample.guilog has been generated. If you need to perform these tasks, see Quick Start: Generate and execute a test scenario.

We recommend you copy those templates you need to customize from the $GGCDIR/template directory into your own working directory, and make any changes needed there.

About this task:

A template is used to generate a block of code. The GGC provides default templates, which you can replace with your own custom templates. For this quick start, you use your Genero BDL knowledge to customize the template check_form_name.4gl, the code that is inserted when you generate a test that checks the form name. You will update this template to check that the form name is "price".

Steps

  1. Create your custom template directory.
    This example uses a directory named /mycustom_template_dir.
  2. Navigate to the $FGLDIR/testing_utilities/ggc/template/bdl/atlernate-checks directory.
    Copy the check_form_name.4gl template to your custom template directory
  3. Edit the check_form_name.4gl file as shown.
    !! Validates the current form name
    !! This check is enabled if --check-all or --check-form parameter is used.
    !!
    !! Parameters:
    !!    . formName  : The name of the current form
    !!
    
        IF "$(formName)" == "price" THEN
          DISPLAY "It is the price form "
          # Ensure the form name is: $(formName)
          CALL ggc.assert(ggc.getFormName() == "$(formName)", SFMT("Form name is not valid, expected: '$(formName)', got: '%1'", getFormName()))
        ELSE    
           DISPLAY "Skipping form check on " || "$(formName)"
        END IF
    The template is modified to check for the "price" form only. The check is skipped for all other forms.
  4. Generate the scenario from the GUI log.
    ggcgen bdl --template-directory path\to\mycustom_template_dir --check-form price_sample.guilog
    Where:
    • --template-directory option specifies the path to the custom template directory.
    • --check-form parameter runs checks for the form name and title.
    • The price_sample.guilog is used to generate the scenario.

    The file price_sample.4gl is the created test scenario.

  5. Compile the scenario.
    fglcomp price_sample.4gl

    The generated test scenario compiles and creates the application file price_sample.42m.

  6. Type the following command to run the test:
    fglrun price_sample tcp --command-line "fglrun price"

    Where the path to the test application (price_sample) and the application being tested (price) is the current working directory.

The test runs and the results display in the output. Based on your customization, you can see when the name of the price form is checked versus when the name of the edit_price form is checked. Your output will depend on the interaction you recorded in your guilog.
Figure: Output for customization quick start