Building a test case for a program with a dynamic call using the AZUTSTRN runner

When you create/modify a test case for a program that makes a dynamic call to a subprogram, the z/OS® Automated Unit Testing Framework (ZUnit) generates a wrapper program that must be link-edited with the generated stub program. The wrapper program, the stub program, the test target source program, and the test case program require specific compiler and link options for the test case program to run correctly.

Before you begin

This procedure requires a COBOL source program that makes a dynamic call to a subprogram.

About this task

When you build a ZUnit test case program, you must specify DYNAM(DLL) in the link options of the property group that is associated with the test target source program. If the test target source program includes a dynamic call to a subprogram, however, the property group must not include the DYNAM(DLL) link option. Moreover, ZUnit generates a stub program for a subprogram that is started by using a dynamic call with the NODLL compiler option, but the stub program must specify the DLL compiler option in its call to the ZUnit runner API. To handle these conflicting compilation and linking requirements, ZUnit generates a wrapper program, called ZUTW01.cbl, that must be link-edited with the generated stub program in order for the test runner to handle the dynamic call correctly.

Procedure

To generate and build a test case program for a test target source program that makes a dynamic call to a subprogram:

  1. Create a property group and associate it with the test target source program. Specify these link step options on the Link page of the property group. Notice that the Link options field does not include the DYNAM(DLL) option. For all other properties, specify the values that are described in Setting link options for a COBOL test case for AZUSTRN runner.
    Link step options for testing a program that makes a dynamic call
  2. Select a COBOL source program that makes a dynamic call to a subprogram, and generate a test case for it by following the procedure in Creating/modifying a test case.
  3. Add test data to the test case by following the instructions in Editing test cases and its subtopics.
  4. To generate the stub program and the test case program, click the Generate Programs toolbar button Generate toolbar button. On the Generation Programs window, be sure to select the stub program.
    ZUnit generates the following COBOL programs:
    • The test case program
    • The stub program
    • The wrapper program, called ZUTW01.cbl
    Tip: Open the stub program and the wrapper program in an editor and notice the compiler options that are generated in the PROCESS statement of each program:
    • The stub program includes the NODLL, NODYNAM options.
    • The wrapper program includes the DLL, NODYNAM options.
    This example shows the PROCESS statements highlighted in a generated stub program called SUB1.cbl and in a generated wrapper program called ZUTW01.cbl.PROCESS statements
  5. Create and submit JCL to compile and link-edit the stub program and ZUTW01.cbl.
    1. In the JCL file, specify the DYNAM(DLL) link option for the stub and wrapper programs, as shown in the sample code.
    2. Link-edit the stub and wrapper programs as the stub program load module name.
      The wrapper program should be linked later than the stub program.
      In this example, the DYNAM(DLL) link option is specified for the stub and wrapper programs. The stub program is named SUB1.cbl. Therefore, the stub program and the wrapper program are link-edited as load module <HLQ>.ZUNIT.COBOL.LOAD(SUB1):
      
      //LKED EXEC PROC=ELAXFLNK,
      // PARM.LINK=('DYNAM(DLL)',
      // 'NOREUS')
      //LINK.SYSLIB DD DSN=CEE.SCEELKED,
      //            DISP=SHR
      //LINK.OBJ0000 DD DISP=SHR,
      //        DSN=USER33.ZUNIT.COBOL.OBJECT(SUB1)
      //LINK.OBJ0001 DD DISP=SHR,
      //        DSN=USER33.ZUNIT.COBOL.OBJECT(ZUTW01)
      //LINK.SYSLIN DD *
           INCLUDE OBJ0000
           INCLUDE OBJ0001
           INCLUDE AZUTSTRX
      /*
      //LINK.SYSLMOD   DD  DISP=SHR,
      //        DSN=USER33.ZUNIT.COBOL.LOAD(SUB1)
      
  6. To run the test case, select the test target source program, and then select z/OS Automated Unit Testing Framework (ZUnit) > Run Test Case.