Test Data Optimization


In this Test Drive, we will demonstrate the usage of Test Data Optimization (TDO). Code Coverage's Test Data Optimization (TDO) identifies records that are active when statements are first marked executed. For programs in which the paths taken are determined by data content on a current input record, TDO can help identify an optimized subset of records that yield an execution percentage that is the same as executing the full set. Testing with this subset of records can significantly reduce execution time and conserve resources. TDO works with sequential files, VSAM and IMS and although it doesn't evaluate Db2 statements, it can still perform with code that has embedded SQL, just note that this code is ignored in the process. TDO uses Code Coverage to determine the unique path through all code and therefore also includes unique paths in called programs. Code Coverage is an option available within Code Debug. To use Test Data Optimization functionality we must therefore execute a Code Debug Batch session and run all data through the debug session.

  • This tutorial will introduce you to how to use Test Data Optimization using BMC AMI DevX Code Debug and Code Coverage. In our case, we use a reporting program with a small input file with 19 records that will result in an output file with 10 unique records.

Instructions:

  • This guide assumes you have completed the "Getting Started" script.
  • This guide assumes you have first completed the "Batch Interactive Debugging Scenario" script.
  • This guide contains many screenshots to provide a visual reference.
  • Every action you must take is in the Info Box.

Setting Up

Test Data Optimization uses DevX Code Debug and Code Coverage. To be able to collect Code Coverage we need to start by creating our own Code Coverage Repository.
Open BMC AMI DevX Workbench. Open the Host Explorer perspective. You should have already created a z/OS dataset filter for CWEZxxx.WBSAMP.* .


Do This
  • Select the z/OS Datasets folder, right-click and select 'Allocate/Define' and in the submenu select the 'Code Debug/Code Coverage Repository...'.


Screenshot 2023-09-12 163120.png


Do This
  • Name the repository using  your Test Drive user ID; CWEZxxx.WBSAMP.COVERAGE and click 'Finish'.  

Screenshot 2023-09-12 163208.png


You can close the screen that confirms the allocation; click 'OK'.

Screenshot 2023-09-12 163259.png


Running the Code Debug Session

We will use an existing JCL that executes program CWXTCOB  and has an input file named CWEZxxx.WBSAMP.JCL(CWXTDATA). 
Expand folder CWEZxxx.WBSAMP.JCL.


Do This
  • Locate the JCL member CWXTJCLC and right-click to display the context menu. Highlight 'Debug As' and click 'Code Debug Batch Session...'.

Screenshot 2023-09-12 163505.png 


When we have an existing Debug Configuration for this JCL, the following screen will pop-up:

Screenshot 2023-08-10 141903.png

Click 'Open'.


If no prior configuration was created, this step is skipped and the Debug Configuration screen opens with the details from the selected JCL.
If you have not switched off this pop-up, you will see the following request. Click 'Switch'.

popup debug.jpg


Do This
  • Click first on the 'Autofill' button to ensure the correct steps and names are used from current JCL. 
  • Click the Code Coverage tab.

Screenshot 2023-09-12 163701.png


Do This
  • Fill in the Code Coverage Repository name using the same name we used in the Getting Started section. Select the checkboxes according to the example. Using the black arrow down in front of 'Test Data Optimization', expand the screen to be able to select the Enable TDO checkbox. Name the TDO dataset name as CWEZxxx.WBSAMP.TDOCNTL with your own user ID as the prefix. Disposition 'DELETE' makes sure that you do not accidentally append to an existing result in case of a rerun.
  • Click 'Debug'.

Screenshot 2023-09-12 163851.png


If this is the first time executing this Test Drive, you may see a window pop-up message appear. Just press 'Ignore' for this, it is just a warning that the file does not exist.

Screenshot 2023-09-12 163907.png


The DevX Code Debug perspective will populate several views. The main program will encounter a default breakpoint at the procedure division entry point.


Do This
  • In the Debug view, click the green 'Resume' button (see red box close to the left of screen). This will process all data since there are no other breakpoints set in the code.  

Screenshot 2023-09-12 164152.png


You should see on the bottom right of the window a pop-up message appear indicating that the job has ended.

Screenshot 2023-08-10 142832.png

You will be asked if you want to open the Code Coverage Perspective, answer this with 'Yes'.

Screenshot 2023-09-06 100518.png

The Code Coverage perspective is now open and shows per program the percentage of Cobol statements covered by this test run. 

Screenshot 2023-09-12 164355.png

Close the Code Coverage perspective by right-click and slect 'Close'.

Screenshot 2023-09-06 100657.png

Close the Code Debug perspective by right-click and select 'Close'.

Screenshot 2023-08-10 142908.png

You may need to close some Views that are left open.

Do This
  • To see the result of our Test Data Optimization, refresh the Workbench View by selecting our filter 'CWEZxxx.WBSAMP' and use the 'refresh' button. The CWEZxxx.WBSAMP.TDOCNTL should appear in the list. 

Screenshot 2023-09-12 164545.png


Generating the New File with Unique Test Cases 

TDO will generate a special instruction file containing BMC AMI File-Aid control statements (in our case CWEZxxx.WBSAMP.TDOCNTL) that we will use in a simple JCL with one File-Aid step. This JCL generates the data file containing only the records that had a unique path through the code. The content of the control statement file is a list of statements that either select a (number of) record(s) or skip a (number of) record(s).


Screenshot 2023-09-12 164639.png



Do This
  • Right-click on the 'TDOJCL' member and click 'Submit'.  

Screenshot 2023-09-12 164734.png


Note that the input file used is actually a member inside the JCL PDS 'CWEZxxx.WBSAMP.JCL(CWXTDATA)' and the output file containing only the selected records will be 'CWEZxxx.WBSAMP.TDOOUT'. 

 


You get a message to confirm the job was successfully submitted, click 'OK'.

Screenshot 2023-09-12 164816.png




Validating the Optimization Results

Via the Workbench Explorer, open for edit (by double-clicking on the name) 'CWEZxxx.WBSAMP.JCL(CWXTJCLC)'


Do This
  • Replicate the //EMPFILE  line and comment out the first.
  • Change the name of the DSN to the name you see here in the screen print: 'DSN=&SYSUID..WBSAMP.TDOOUT,DISP=SHR '.

Screenshot 2023-09-12 165030.png


Do This
  • Right-click in the JCL and click 'Debug As' then 'Code Debug Batch Session...'

Screenshot 2023-09-12 165646.png


Save the JCL as requested.

Screenshot 2023-09-06 170545.png



Use the existing configuration.

Screenshot 2023-09-06 170714.png


If you have not switched off this pop-up, you will see the following request. Click 'Switch'.

popup debug.jpg



Do This
  • Open the Code Coverage tab by clicking on it. 
  • Make sure the 'Test Data Optimization' box is DE-selected.
  • Click 'Debug'.

Screenshot 2023-09-12 165740.png


Do This
  • In the debug view, click the green 'Resume' button (see red box close to the left of screen).

Screenshot 2023-09-12 164152.png

Select 'Yes' to open the Code Coverage perspective.

Screenshot 2023-09-06 171527.png

Do This
  • Note that we have exactly the same percentages of Code Coverage but this time we used a file that contained almost half the number of records as before.

Screenshot 2023-09-12 170120.png

As before, close both the Code Coverage and Code Debug perspectives and the CWXTCOB annotated listing.

Screenshot 2023-09-06 172010.png

Make sure to restore the JCL to its original state!!

Screenshot 2023-09-12 170233.png

Close the JCL and click 'Yes' to save the changes.

Screenshot 2023-09-06 172255.png

Conclusion

Test Data Optimization is especially useful if full sized production datasets are used to verify changes.  In our example, the test set went from 19 input records to 10. Even though this is a small sample, you can see the difference. In very large files, the difference will be dramatic, changing from possibly tens of thousands to just dozens, thereby greatly reducing testing execution times. 

 

Tip: For faster searching, add an asterisk to the end of your partial query. Example: cert*