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:

To complete this quick start, it is assumed that you have downloaded and installed the GGC package. If you need to perform this task, go to Install the GGC package.

You should have compiled the price application in the $GGCDIR/src/quick-start and generated the log file price_sample.guilog. If you need to perform these tasks, go to Quick Start: Generate and execute a test scenario.

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

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 $GGCDIR/ggc/template/bdl/alternate-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. Start the GGC server.
    Before you execute a test scenario, you must start the GGC server. To continue in the same terminal window, you must run the command in the background; alternatively, you can open another terminal to start the GGC server from.
    • UNIX® like OS:
      ggcadmin startbdlserver &
    • Windows®: Use "start /min" to have the command run in a new, minimized window:
      start /min ggcadmin startbdlserver
  7. 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


    Note: The output is intended as a sample to show test session statistics, the format may change in future product releases.