PreviousMaintaining a DB2 Database Year 2000 TestingNext"

Chapter 27: Regression and Conformance Testing

TouchPoint provides enhanced, testing-specific functionality from within the Mainframe Express Integrated Development environment. This tutorial covers the basic features of TouchPoint by demonstrating how to use them. It leads you step-by-step through the creation of a project and then, using a very simple application, shows you how to create and execute regression and conformance tests.


You need to have read the chapter Start Here for the Tutorials and worked through the first session, Using Mainframe Express, before you do this session.


27.1 Overview

Before attempting to use TouchPoint, you need to understand the following terms:

Now that you are familiar with this basic terminology, try running the following tutorial.

27.2 Creating a Mainframe Express Project

Before you can use TouchPoint to perform any kind of testing on your application, you must create a Mainframe Express project for that application.

27.2.1 Creating a Project

Included with your Mainframe Express software is a very simple program, fragsamp.cbl, which is used with this tutorial to demonstrate the main TouchPoint features. The fragsamp.cbl program can be found in the mfuser\projects\gsdemo\fragdemo\source directory. To create a Mainframe Express project for fragsamp.cbl:

  1. Start Mainframe Express, click New on the File menu, then select Project on the New dialog box and click OK.

  2. Enter FragDemo as the name of the project and change the default Project Folder name to drive:\mfuser\projects\Gsdemo\FragDemo, (in other words, insert \Gsdemo into the pathname), then click Next.

  3. Select Using this wizard as your chosen method of creating the project and click Next.

  4. Leave the default folder for the catalog (\mfuser\projects\Gsdemo\FragDemo) unchanged and click Next.

  5. If you have installed any Mainframe Express options, a dialog box is displayed prompting you to specify which of those options this project uses. It does not use any Mainframe Express options, so ensure that all the boxes are unchecked and click Next.

  6. Click Finish to create the project.

27.2.2 Adding Files to the Project

You need to add two files to the project (fragsamp.cbl and fragsamp.tso):

  1. Click Add Files on the Project menu.

  2. In the Add Files to Project dialog box, open the folder mfuser\projects\Gsdemo\Fragdemo\Source.

  3. Select Fragsamp.cbl and Fragsamp.tso (hold down the Ctrl key to select more than one file) and then click Add to add the files to the project.

    The files are added to the project.

  4. Click Done. The files that you have added are parsed.

27.2.3 Modifying the Build Settings

The COBOL dialect for FRAGSAMP.CBL is COBOL for MVS, so:

  1. Right-click on FRAGSAMP.CBL in the right-hand pane and select Build Settings for FRAGSAMP.CBL from the context menu.

  2. Select COBOL for MVS as the COBOL dialect.

  3. Click OK.

27.2.4 Compiling the Program

You cannot use TouchPoint to create fragments for a program until that program has been compiled:

  1. Ensure FRAGSAMP.CBL is selected by clicking on it and then either select Compile FRAGSAMP.CBL from the Build menu or right-click on FRAGSAMP.CBL and select Compile FRAGSAMP.CBL from the context menu. The message Compilation complete with no errors is displayed in the Build tab of the Mainframe Express Output window when the compilation is complete. (If you can't see the Mainframe Express Output window, enable it by selecting Output from the View menu and then click the Build tab.)

27.2.5 TouchPoint Output Window

For the purposes of this tutorial, it is important that the TouchPoint Output Window is floating on the desktop:

  1. Select Dockable Windows from the View menu, ensure that TouchPoint Output is checked and then click Close. The TouchPoint Output window is displayed, greyed out, with the text TouchPoint application output window unavailable displayed within it.

  2. Right-click within the TouchPoint Output window and ensure that Float on desktop is checked.

  3. Close the TouchPoint Output window by clicking on its button.

27.2.6 Debug Options

Check that your debug options are set correctly for running this tutorial:

  1. Select Debug from the Options menu.

  2. Ensure that Step/Run displays Start Debugging dialog is checked.

  3. Click OK.

27.3 Deciding What to Test

TouchPoint can be used very effectively to perform either:

In either case, the first step is to define those areas of your program that need to be tested. These may be modules that you intend to change (in the case of regression testing) or modules that perform a specific function (in the case of conformance testing). Any piece of code that you need to test must be defined as a TouchPoint code fragment.

27.4 Regression Testing

TouchPoint makes regression testing easy by enabling you to create and run tests for the section of code that you are going to change, before you make the changes. This gives you a baseline. After you have made your changes you can run the same test again. Comparing the new results with the baseline enables you to spot regressions in your code.

  1. Click the Files tab.

  2. Double-click on FRAGSAMP.CBL to open it in the editor.

  3. Take a few minutes to scroll through the code and become familiar with it. It is a very simple demonstration program. The CALC-TOTAL-IN-MONTH section reads through an array of records comparing the date held in each record to the date held in the data item, REQUIRED-MONTH. If they match, the data items DATE-COUNT and VALUE-TOTAL are incremented.

Using the CALC-TOTAL-IN-MONTH section, this tutorial demonstrates how you can make changes to your code and then use TouchPoint to perform regression tests. Each step in the process is outlined below and described in detail in the following pages.

27.4.1 Defining a Fragment

The first stage in regression testing is to define the piece of code that you are going to change as a code fragment. In this case, the code that we are going to change is the CALC-TOTAL-IN-MONTH section.

  1. Within the editor, select the first executable line of the CALC-TOTAL-IN-MONTH section:
    MOVE 1 TO ARRAY-INDEX
    and then, holding down the left mouse button, extend the selection to the last line of the section:
    END-PERFORM.
  2. Select New from the Fragment menu. The dialog box shown in Figure 27-1 is displayed.



    Figure 27-1: Defining a Fragment

  3. The default code fragment name of Program-name_n (so, in this case, FRAGSAMP_1) is displayed. You must enter a fragment name, or use the default supplied by TouchPoint. For the purposes of this tutorial, accept the default.

  4. You do not have to enter a description, but it is advisable to do so as this will make it easier to identify the fragment later, when you have created many more. Enter the name of the COBOL section, CALC-TOTAL-IN-MONTH, as the description.

  5. Because the code fragment is currently selected, the name of the program and the line numbers at which the fragment starts and ends (these are the sequence numbers used within the editor) are displayed. It is possible to enter this information manually, or to alter the selection and then press the Use current selection button. For now, accept the current selection by clicking Next. An error message is displayed informing you that the last line of the selected code fragment is invalid. This message is displayed now because when you click Next to accept the currently selected code, that code is parsed:

    Comment lines and section or paragraph names are invalid at the start of a selection because the fragment must start on an executable line. A fragment cannot end with an END-IF statement because, given an IF, ELSE, END-IF construct, the END-IF statement will never be executed if the condition is true. A fragment cannot end with an END-PERFORM statement because the PERFORM loop would only be executed once.

    The currently selected code ends with an END-PERFORM statement. As this is invalid, TouchPoint displays an error message. You can choose to allow TouchPoint to redefine the code fragment such that it is no longer invalid. In this case, TouchPoint would achieve this by extending the selection to the next executable line (MOVE 0 TO MATCH-INDEX). This would work, but it is equally effective, and neater, to simply insert a CONTINUE statement at the end of the fragment.

  6. Click Cancel to close the message box and then click Cancel again to close the Define Code Fragment dialog box.

  7. Add a CONTINUE statement as the very last statement of the CALC-TOTAL-IN-MONTH section.

  8. Re-compile FRAGSAMP.CBL by clicking on the button on the toolbar.

  9. Select the CALC-TOTAL-IN-MONTH section again, this time with MOVE 1 TO ARRAY-INDEX as the first line and CONTINUE as the last line and then select New from the Fragment menu.

  10. Enter the section name as the description and click Next. This time the Define Input and Output Variables dialog box is displayed.

27.4.2 Defining Input and Output Variables

You must define at least one output variable for a fragment.

In addition, for fragment testing, you must define at least one input variable.

The dialog box shown in Figure 27-2 enables you to define input and output variables.



Figure 27-2: Defining Input and Output Variables

An input variable is a data item that is used to feed data into a code fragment. For fragment tests, you can specify the value of the input variables used by the fragment. You can define more than one value for an input variable - the fragment is executed once for each value that you specify. (You do not have to supply values for all the input variables that you define. If you do not specify a value for an input variable, its value is taken from the set of initial values used by the test.)

With the CALC-TOTAL-IN-MONTH section, the result output by the fragment depends on the value fed into the fragment via the data item, REQUIRED-MONTH. So, this fragment could be tested by varying the values supplied in REQUIRED-MONTH and monitoring the results.

In order to do this, you must define REQUIRED-MONTH as an input variable but at the moment it does not appear in the list of data items:

  1. Click Show Related Data. This updates the list of data items to include all the data items that are related to those already listed. Note that REQUIRED-MONTH is displayed now because it is the parent data item of REQUIRED-MONTH-MM and REQUIRED-MONTH-YY.

  2. Select REQUIRED-MONTH-MM and REQUIRED-MONTH-YY by clicking on them (hold down the Ctrl key to select more than one data item) and then click the Add button below Input Variables.

  3. Select DATE-COUNT and VALUE-TOTAL by clicking on them and then click the Add button below Output Variables. An output variable is a data item whose value is recorded when a test is run. The result of feeding different values of REQUIRED-MONTH into CALC-TOTAL-IN-MONTH can be monitored by recording the values output in DATE-COUNT and VALUE-TOTAL.

  4. Click Next. The Initial Value Creation dialog box is displayed.



    Figure 27-3: Initial Value Creation

From the Initial Value Creation dialog box you can:

  1. Accept the default selection, Defer the creation of initial values and click Finish.

  2. Close the editor window by clicking on its button.

You can check that your code fragment (FRAGSAMP_1) has been created by clicking the Tests tab on the Project View. The new fragment is listed under Closed Code Fragments, as shown in Figure 27-4.



Figure 27-4: The Tests View of the Project


Note: The WinRunner details are only displayed if you have WinRunner 2000 installed.


27.4.3 Generating Initial Values

Having deferred initial value creation during fragment definition, you must generate some initial values before you can create a fragment test.

Initial values are used when the fragment test is run to provide meaningful values for all the data items used by a fragment, enabling it to be executed in isolation from the rest of the application.

You can generate initial values manually (the fragment must be selected in the Tests View for this option to be enabled), or by running the application. To generate initial values via application execution:

  1. Select Initial Values from the Fragment menu and then select Generate By Execution. The dialog box shown in Figure 27-5 is displayed.



    Figure 27-5: Generating Initial Values by Execution

  2. You must enter a name for the initial values group. The description is optional. Normally, you should make these as meaningful as possible but for the purposes of this tutorial simply accept the default name, InitialValues1 and enter a description of Fragsamp.

  3. Ensure that FRAGSAMP_1 is selected in the list of fragments and then click OK. The Testcase Parameters dialog box is displayed, as shown in Figure 27-6. Click the TSO tab and enter the full pathname of the fragsamp.tso file (drive:\mfuser\projects\gsdemo\FragDemo\SOURCE\FRAGSAMP.TSO) as the Clist to execute.



    Figure 27-6: Testcase Parameters Dialog Box

  4. Click OK to run the application. As the application runs, values are recorded for every data item within the fragment, FRAGSAMP_1. Note that a data item value is recorded only once, the first time that the fragment is encountered and that the data values are stored at the point where program execution reaches the first line of the fragment. Information is displayed in both the Mainframe Express Output window (to inform you that a fragment has been encountered and initial values have been stored for it) and the TouchPoint Output window (displays any normal application output). When the application terminates a message box is displayed (as shown in Figure 27-7), telling you which fragments have been encountered. Initial values are generated for each fragment encountered.



    Figure 27-7: Initial Value Generation Status

  5. Click OK to close the message box.

27.4.4 Creating a Fragment Test

Once you have defined a fragment and generated some initial values for it, you can create a fragment test:

  1. Select New from the Test Case menu. The dialog box shown in Figure 27-8 is displayed. (If you have WinRunner 2000 installed, a third option, WinRunner Script, is also displayed.)



    Figure 27-8: Selecting the Type of Test

  2. Select Fragment by clicking on it and click OK. The dialog box shown in Figure 27-9 is displayed.



    Figure 27-9: Defining a Fragment Test

  3. Accept the default name of FragmentTest_1 and enter CALC-TOTAL-IN-MONTH (the name of the COBOL section) as the description.

  4. Each fragment test can cover only one fragment. You must select which fragment this test covers by selecting the fragment name from the drop-down list. Select FRAGSAMP_1 and click Next.

  5. You are prompted to select the initial values that you want to use, as illustrated in Figure 27-10. Only those initial values that are associated with the chosen fragment are displayed. You can only use one set of initial values per fragment test. Select the initial values that you created earlier (InitialValues1) and then click Finish. This creates the (empty) fragment test.



    Figure 27-10: Selecting the Initial Values

The fragment test worksheet, shown in Figure 27-11 is displayed.



Figure 27-11: Fragment Test Worksheet

The fragment test worksheet displays the initial value that will be used for each input variable defined (in this case, only two input variables are defined, REQUIRED-MONTH-MM and REQUIRED-MONTH-YY, so only two values, 01 and 99 are displayed).

The fragment test worksheet enables you to:

Note that clicking on the Cancel button on the fragment test worksheet does not delete the fragment test, which was created when you clicked on the Finish button after selecting the initial values.

27.4.4.1 Input Variable Values

You can use the fragment test worksheet to specify one or more values for each input variable defined. The fragment is executed once for each value that you specify. (The number of times the fragment is executed is referred to as the number of iterations.) To enter an input variable value, right-click in the first empty worksheet cell underneath its name.

  1. Right-click in the REQUIRED-MONTH-MM cell for iteration 1 and then click Range. This enables you to specify a range of values for REQUIRED-MONTH-MM.

  2. Enter 1 in the Start: box, press the Tab key and enter 12 in the End: box. Click OK. This specifies that this fragment test will be run 12 times using values of 01 to 12 for REQUIRED-MONTH-MM. Notice that 1..12 (meaning iterations 1 to 12) now appears under the Iteration heading followed by 13, ready for further input.

  3. Now right-click in the REQUIRED-MONTH-MM cell for iteration 13 (the next cell down), click Range and enter 1 in the Start: box and 3 in the End: box before clicking OK. This specifies that the fragment will be executed another 3 times (iterations 13 to 15) using values of 01 to 03 for REQUIRED-MONTH-MM. This time the text 13..15 is entered under the Iteration heading, followed by 16, ready for further input.

  4. Now right-click in the REQUIRED-MONTH-YY cell for iterations 1 to 12. Notice that, because you have already entered a range of values for REQUIRED-MONTH-MM, Range, Increment, Date and Use are greyed out. Click Single Value to display the dialog box shown in Figure 27-12:



    Figure 27-12: Enter Single Value

    Enter 99 and then click the button so that you can enter a value for iterations 13 to 15. Enter a value of 00 and then click the button.

What you have done is to specify that the FRAGSAMP_1 fragment (the CALC-TOTAL-IN-MONTH section) will be executed 15 times in total using values of REQUIRED-MONTH between January 1999 and March 2000.

27.4.4.2 Compare Baseline

The fragment test worksheet also enables you to specify whether, when this test is run, output variable values are compared to the baseline. (You can record baseline values for a test using a special TouchPoint function - see Recording a Baseline below.) Baseline comparison is the very essence of regression testing so it is switched on by default - Yes is displayed in the Compare Baseline column for all iterations.

  1. For iterations 1 to 12, right-click in the cell beneath the heading Compare Baseline. Notice that Compare baseline values is checked. You could switch baseline comparison off from here by clicking Compare baseline values but for regression testing, baseline comparison is required so leave it unchanged by pressing the Esc key. (You can toggle baseline comparison on and off for an iteration at any time by double-clicking in the Compare Baseline column for the iteration that you want to alter).

27.4.4.3 Condition

For each iteration of the test that you want to perform, you can specify any valid COBOL condition to be tested at the end of that iteration.

Details of how to specify validation criteria are given later in this tutorial. See Validation Criteria within the section Conformance Testing for details.

27.4.4.4 Closing the Worksheet

Once you have entered all the information that you need, close the fragment test worksheet by clicking on the OK button.

27.4.5 Recording a Baseline

Once you have created your test, you can record a baseline for it. Then later, when you have made changes to your code, you can run the same test again and compare the new results with the baseline.

To record a baseline:

  1. Select the test by clicking on it (make sure you have the Tests View selected and click Closed Code Fragments so that your test is shown in the right-hand pane). Once the test is selected, click Record on the Test Case menu.

    The test is run and values are recorded for the output variables. For a fragment test, output variable values are recorded for each iteration of the test. Progress information is written to the Mainframe Express Output window. When all iterations have been run, a message box is displayed indicating that the recording is complete.


    Notes:

    1. The amount of information that is displayed in the Build tab of the Mainframe Express Output window by TouchPoint is configurable via the Tests item on the Options menu. TouchPoint tests run faster if the display of information in the Output window is suppressed.

    2. Display of the message box indicating that recording is complete is configurable via the Tests item on the Options menu.


  2. Click OK to close the message box.

Notice that the date and time at which the baseline was recorded are now displayed in the Tests View of the project under Last Update.

27.4.6 Analyzing the Baseline

You can inspect the baseline values that have been generated:

  1. Select the test in the right-hand pane by clicking on it.

  2. Select Analyze from the Test Case menu.

  3. A message is displayed informing you that no results are available for the test and that the baseline values will be displayed. Click OK to close the message box and display the Analyze Fragment Test dialog box illustrated in Figure 27-13.



    Figure 27-13: Analyzing the Baseline

    In the left-hand pane the status of each iteration is displayed (at this stage, the test has not been run and so the status of each iteration is shown as "-"). You can select an iteration by clicking on it. In the top right-hand pane, you can see the value of the input variables for the selected iteration. In the bottom right-hand pane, you can see the recorded (baseline) values of the output variables for the selected iteration. By moving through the iterations one by one you can see how the value of the input variables affects the value of the output variables.

    This is your baseline. If you add new features to your code you can run the same test again and compare the output variable values to this baseline to ensure that your changes have not "broken" your code.

  4. Close the Analyze Fragment Test dialog box by clicking Close.

27.4.7 Changing your Code

Once you have created your test case and recorded a baseline, you can make the changes to your code:

  1. Click the Files tab in the Project View and then double-click on FRAGSAMP.CBL to open it in the editor.

  2. Find the CALC-TOTAL-IN-MONTH section and uncomment the lines that are commented out:
    MOVE 0 TO BEFORE-TODAY-COUNT AFTER-TODAY-COUNT
    MOVE 0 TO BEFORE-TODAY-TOTAL AFTER-TODAY-TOTAL
    .
    .
    .
    IF CURRENT-EXPIRY-DATE < TODAYS-DATE
       ADD 1 TO BEFORE-TODAY-COUNT
       ADD CURRENT-VALUE TO BEFORE-TODAY-TOTAL
    ELSE
       ADD 1 TO AFTER-TODAY-COUNT
       ADD CURRENT-VALUE TO AFTER-TODAY-TOTAL
    END-IF
    ADD 1 TO ARRAY-INDEX

    This additional code adds new functionality to CALC-TOTAL-IN-MONTH by comparing the date held in each record to the date held in the TODAY-DATE data item. Depending on the result of the comparison it then increments one of two running totals: BEFORE-TODAY-TOTAL or AFTER-TODAY-TOTAL. Note that it also, erroneously, adds a statement which increments ARRAY-INDEX.

  3. Save and compile FRAGSAMP.CBL by clicking on the button on the toolbar. The message Compilation complete with no errors is displayed in the Mainframe Express Output window.

  4. Close the editor window by clicking on its button.

27.4.8 Running a Regression Test

After you have made fixes to your code, you can perform regression testing on your application by re-running the test that you recorded earlier. This enables you to compare the new output variable values with the baseline and spot any regressions in your code.

To run a test:

  1. Select the test in the right-hand pane of the Tests View of the project.

  2. Select Run from the Test Case menu.

The test is run and the value of each output variable is recorded once for each iteration. In the Tests View, the date and time at which the test was last run is displayed under Last Run (you may need to scroll, or adjust the size of the right-hand pane to see this information). The test status, Fail, is also displayed:

27.4.9 Analyzing the Results

Once you have run your test, TouchPoint includes built-in analysis facilities to help you analyze the results:

  1. Select the test by clicking on it and then select Analyze from the Test Case menu to display the Analyze Fragment Test dialog box illustrated in Figure 27-14.



    Figure 27-14: Analyzing Test Results

    In the left-hand panel, a status is displayed for each iteration:

    You can select an iteration by clicking on it in the left-hand panel. For the currently selected iteration the values of any input variables are displayed in the top right-hand panel and, for each output variable, the following information is displayed:

    As you can see, the statement that was added in error has caused the test to fail.

  2. Close the Analyze Fragment Test dialog box by clicking Close.

27.4.10 Correcting your Code

You can correct your code and re-run the test as many times as is necessary to eliminate regression errors.

  1. Click the Files tab in the Project View and then double-click on FRAGSAMP.CBL to open it in the editor.

  2. Find the CALC-TOTAL-IN-MONTH section and comment out the first ADD 1 TO ARRAY-INDEX statement.

  3. Save and compile FRAGSAMP.CBL by clicking on the button on the toolbar. The message Compilation complete with no errors is displayed in the Mainframe Express Output window.

  4. Close the editor window by clicking on its button.

  5. Now run the test again by right-clicking on it in the right-hand pane of the Tests View of the project and selecting Run from the context menu. This time the test status is shown as Pass.

  6. Right-click on the test and select Analyze.

  7. Select each iteration in turn to confirm that the baseline values match the test result values for every iteration. As the status of each iteration, and therefore the entire test, is Pass, you can be confident that your code changes have not caused any regression errors in your code. Click Close to close the Analyze Fragment Test dialog box.

27.5 Conformance Testing

Unlike regression testing, the expected results for conformance testing cannot be generated automatically by TouchPoint. Only someone who is familiar with the application and its data can know what the correct results should be when new data is supplied to it. Given that knowledge, however, TouchPoint can automate and simplify the testing process. TouchPoint provides two methods of performing conformance testing on your program:

If you have not done so already, take a few minutes to examine the program FRAGSAMP.CBL and become familiar with it. The GET-NEAREST-TO-DATE section reads through an array of records comparing the date held in each record to the date held in the data item, REQUIRED-DATE and then displays the record which contains the date that is nearest to that held in REQUIRED-DATE.

Using the GET-NEAREST-TO-DATE section, this tutorial demonstrates conformance testing by feeding in dates up to and beyond the beginning of the Year 2000. Each step in the process is outlined below and described in detail in the following pages.

27.5.1 Defining a Fragment

As with regression testing, any piece of code on which you need to perform conformance testing must be defined as a TouchPoint code fragment. To create a fragment:

  1. Return to the Files View and double-click on FRAGSAMP.CBL to open the editor.

  2. Within the editor, select the first line of the GET-NEAREST-TO-DATE section:
    MOVE 0 TO MATCH-INDEX
    and then, holding down the left mouse button, extend the selection to the last line of the section:
    CONTINUE.

    Note that this CONTINUE statement has been added to the end of the section to avoid its ending with an END-PERFORM statement.

  3. Right-click with the mouse and select Create Code Fragment from the context menu.

  4. Accept the default fragment name of FRAGSAMP_2 and enter the section name, GET-NEAREST-TO-DATE, as the description.

  5. Because the code fragment is currently selected, the name of the program and the line numbers at which the fragment starts and ends (these are the sequence numbers used within the editor) are displayed. Accept these by clicking Next.

  6. Click REQ-DATE and then the Add button below Input Variables.

  7. Click NEAREST-RECORD and then the Add button below Output Variables.

  8. Click Next.

  9. Click Generate initial values by executing the application, accept the default name of InitialValues2 and enter the COBOL section name, GET-NEAREST-TO-DATE, as the description before clicking Next.

    The Generate Initial Values by Execution dialog box, shown in Figure 27-15 is displayed.



    Figure 27-15: Generating Initial Values by Execution

  10. Select the fragment that you are defining, FRAGSAMP_2, by clicking on it and click Finish. The Testcase Parameters dialog box is displayed.

  11. Click the TSO tab and enter the full pathname of the fragsamp.tso file (drive:\mfuser\projects\gsdemo\FragDemo\SOURCE\FRAGSAMP.TSO) as the Clist to execute. Click OK to run the application.

  12. Click OK to close the Initial Value Generation Status dialog box that is displayed when initial value generation is complete.

  13. Close the editor window by clicking on its button.

27.5.2 Creating a Fragment Test

Once you have created a fragment and recorded some initial values you can create a fragment test:

  1. Select New from the Test Case menu.

  2. Select Fragment and click OK.

  3. Enter a name and a description for the test. You should always make these as meaningful as possible so that you can recognize the test from its name and description when it is displayed within a list of tests. For the purposes of this tutorial, accept the default name of FragmentTest_2 and enter a description of GET_NEAREST_TO_DATE.

  4. Each fragment test can cover only one fragment. You must select which fragment this test covers by selecting the fragment name from the drop-down list. Select FRAGSAMP_2 and click Next.

  5. You are prompted to select the initial values that you want to use. Only those initial values associated with the fragment are displayed. Select InitialValues2 and click Finish.

The fragment test worksheet, as illustrated in Figure 27-16, is displayed enabling you to enter values for the input variable (REQ-DATE) that you defined for the fragment.



Figure 27-16: Define Input Variable Values

27.5.2.1 Input Variable Values

To enter a range of values for REQ-DATE, right-click in the cell for iteration 1 and then select Date. The dialog box shown in Figure 27-17 is displayed.



Figure 27-17: Specifying a Range of Dates

You can specify a single date, or a range of dates for an input variable. We are going to specify a range of dates, from December 25th 1999 to January 8th 2000.


Note: The date format that you select must match the picture clause of the data item. You cannot, for example, specify a date format of YYYYMMDD if the picture clause of the data item is PIC 999999.


To specify a range of dates for REQ-DATE:

  1. Click Range.

  2. Select YYMMDD as the Format.

  3. Set the Start Date to 25 December 1999. (Click the down-arrow and then on the year. A spin control appears - use this to set the year to 1999 and then press Enter. Now click on the month - a popup menu of months is displayed - and select December. Finally, click on the number 25 to set the date to the 25th.)

  4. Set the End Date to 08 January 2000.

  5. Set the Step Size to 1 day.

  6. Click OK to close the Date Entry dialog box. Notice that 1..15 now appears under the heading Iteration.

27.5.2.2 Compare Baseline

By default, Compare Baseline is switched on. This feature, although essential to regression testing, is not required for conformance testing.

  1. Double-click in the Compare Baseline column to switch baseline comparison off. (The word No is displayed in the Compare Baseline column.)

27.5.2.3 Validation Criteria

For each iteration of the test that you want to perform, you can specify any valid COBOL condition to be applied to the result of that iteration.

This is the essence of conformance testing - specifying a COBOL condition which, if satisfied, proves that your code conforms to the criteria that you have set. You need to be familiar with your code, and the data it uses, to be able to specify suitable validation criteria.

The GET-NEAREST-TO-DATE section reads through an array of dates looking for the nearest match to the date held in the data item REQUIRED-DATE. Looking at the array of dates, (these are defined in DATE-VALUES in the WORKING-STORAGE section), we can see that the nearest date to every date within the range 25th December 1999 to 8th January 2000, is 4th January 2000. So, in this instance, we can test that GET-NEAREST-TO-DATE is working correctly by specifying a COBOL condition of NEAREST-DATE = 000104.

To specify a COBOL condition:

  1. Right-click in the Condition column for iterations 1 to 15 and select Edit. The dialog box shown in Figure 27-18 is displayed.



    Figure 27-18: Enter COBOL Condition

  2. You can specify any standard COBOL condition here. (Note that the COBOL condition is case insensitive.) Type:
    NEAREST-DATE = 000104

    This specifies that, for any single iteration to achieve a pass status, the value of NEAREST-DATE must be 000104. Notice that the Apply to the current iteration only radio button is selected. You can specify a COBOL condition to be applied to every iteration in a test (Apply to all iterations), to the current iteration (this applies to every iteration in a range if a range is specified) or to every iteration that does not already have a condition specified for it.

    Clicking on the Browse Data button lets you view every data item in the program's WORKING-STORAGE. You can select any of the data items listed for inclusion in the COBOL condition.

  3. Ensure that your COBOL syntax is valid by clicking on the Validate button.

  4. Once you are happy with your COBOL syntax, click OK to exit the Conditional Statement Entry dialog box.

27.5.2.4 Closing the Worksheet

  1. Click OK to close the Define Fragment Test Iteration Values dialog box.

27.5.3 Running a Test

Once you have created your fragment test and specified the validation criteria that will enable you to spot non-conformance within your program, you can run the test:

  1. Select the test (FragmentTest_2) by clicking on it in the right-hand pane of the Tests View of the project.

  2. Select Run from the Test Case menu.

  3. Ensure the Build tab is selected in the Mainframe Express Output window. A message is displayed as each iteration is executed. When the test has run, the message Test FragmentTest_2 completed is displayed.

The status of the test is now displayed as Fail.

27.5.4 Analyzing the Results

To analyze the results of running your test:

  1. Click on the test and then select Analyze from the Test Case menu.

    The Analyze Fragment Test dialog box is displayed, as illustrated in Figure 27-19.



    Figure 27-19: Analyzing Fragment Test Results

    In the left-hand pane, the status is displayed for each iteration:

    You can select an iteration by clicking on it in the left-hand pane. For the currently selected iteration the following information is displayed:

    Select each iteration in turn. Note that every iteration with an input date between 25 December 1999 and 31 December 1999 fails to meet the validation criteria (that the nearest expiry date is 4 January 2000). This is because the GET-NEAREST-TO-DATE section incorrectly converts two digit years to four digit years by adding 19000000 to the data item. It therefore assumes that 99 denotes 1999 and 00 denotes 1900. As the year 2000 dates are incorrectly treated as dates in the year 1900, the greater than/less than comparisons give incorrect results.

  2. Close the Analyze Fragment Test dialog box by clicking the Close button.

27.5.5 Correcting your Code

You can correct your code and re-run the test as many times as is necessary to eliminate errors.

  1. Click the Files tab in the Project View and then double-click on FRAGSAMP.CBL to open it in the editor.

  2. Find the GET-NEAREST-TO-DATE section and un-comment the two commented-out sections of code:
    IF REQUIRED-YY > 50
       ADD 19000000 TO REQ-DATE GIVING INT-REQ-DATE
    ELSE
       ADD 20000000 TO REQ-DATE GIVING INT-REQ-DATE
    END-IF
    .
    .
    .
    IF REQUIRED-YY > 50
       ADD 19000000 TO CURRENT-DATE GIVING INT-EXP-DATE
    ELSE
       ADD 20000000 TO CURRENT-DATE GIVING INT-EXP-DATE
    END-IF

    These sections of code ensure that two digit years beyond the Year 2000 are converted to four digit years correctly.

  3. At the same time, comment out the two ADD statements:
    ADD 19000000 TO REQ-DATE GIVING INT-REQ-DATE
    .
    .
    .
    ADD 19000000 TO CURRENT-DATE GIVING INT-EXP-DATE

  4. Save and compile FRAGSAMP.CBL by clicking on the button on the toolbar.

  5. Close the editor window by clicking on its button.

  6. Now run the test again by right-clicking on it in the right-hand pane of the Tests View of the project and clicking Run. The status of the test changes to Pass.

  7. Right-click on the test and select Analyze from the context menu. Confirm that each iteration now meets the validation criteria specified.

  8. Close the Analyze Fragment Test dialog box by clicking the Close button.

You have now successfully used TouchPoint to find and correct compliance errors in your program.

27.6 Before Continuing

Close the project. If you want to take a break before going on to the next session, you can close Mainframe Express.

Return to the Tutorials Map in the chapter Start Here for the Tutorials and choose which session to go on to next, depending on your interests.


Copyright © 1999 MERANT International Limited. All rights reserved.
This document and the proprietary marks and names used herein are protected by international law.

PreviousMaintaining a DB2 Database Year 2000 TestingNext"