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.* .
You can close the screen that confirms the allocation; click 'OK'.
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.
When we have an existing Debug Configuration for this JCL, the following screen will pop-up:
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'.
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.
The DevX Code Debug perspective will populate several views. The main program will encounter a default breakpoint at the procedure division entry point.
You should see on the bottom right of the window a pop-up message appear indicating that the job has ended.
You will be asked if you want to open the Code Coverage Perspective, answer this with 'Yes'.
The Code Coverage perspective is now open and shows per program the percentage of Cobol statements covered by this test run.
Close the Code Coverage perspective by right-click and slect 'Close'.
Close the Code Debug perspective by right-click and select 'Close'.
You may need to close some Views that are left open.
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).
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'.
Validating the Optimization Results
Via the Workbench Explorer, open for edit (by double-clicking on the name) 'CWEZxxx.WBSAMP.JCL(CWXTJCLC)'
Save the JCL as requested.
Use the existing configuration.
If you have not switched off this pop-up, you will see the following request. Click 'Switch'.
Select 'Yes' to open the Code Coverage perspective.
As before, close both the Code Coverage and Code Debug perspectives and the CWXTCOB annotated listing.
Make sure to restore the JCL to its original state!!
Close the JCL and click 'Yes' to save the changes.
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.