Compuware Test Drive Functional Testing with Topaz for ... Drive/Test Drive XaTes… · This module...

of 50 /50
1 Compuware Test Drive Functional Testing with Topaz for Total Test – COBOL Revised: 1/4/2021 This tutorial will provide you with experience using Topaz for Total Test to execute a functional test for a COBOL program in both batch and CICS environments.

Embed Size (px)

Transcript of Compuware Test Drive Functional Testing with Topaz for ... Drive/Test Drive XaTes… · This module...

  • 1

    Compuware Test Drive

    Functional Testing with Topaz for Total Test – COBOL

    Revised: 1/4/2021

    This tutorial will provide you with experience using Topaz for Total Test to execute a functional test for a COBOL program in both batch and CICS environments.

  • The Mainframe Software Partner for the Next 50 Years

    2

    Contents

    Getting Started with Topaz for Total Test ....................................................................................... 3

    Terminology ..................................................................................................................................... 4

    Restarting This Script ....................................................................................................................... 5

    Topaz for Total Test – Web Interface .............................................................................................. 6

    Topaz for Total Test – Eclipse Interface via Topaz Workbench ..................................................... 15

    Functional Test with Code Coverage ............................................................................................. 40

    NEXT STEPS .................................................................................................................................... 50

  • The Mainframe Software Partner for the Next 50 Years

    3

    Getting Started with Topaz for Total Test

    This test drive will take you through the following activities:

    • Executing a batch COBOL functional test via the Topaz for Total Test web interface

    • Create a test case using Topaz for Total Test via Topaz Workbench

    • Executing a COBOL CICS/Db2 functional test using Topaz for Total Test via Topaz Workbench

    Instructions:

    • This guide contains many screenshots to provide a visual reference

    • Every action you must take is in BOLD

    • Please note each place that you must enter your own specific ID or number

    • You must complete each step before proceeding to the next to successfully follow the guide

  • The Mainframe Software Partner for the Next 50 Years

    4

    During this Test Drive you will encounter terms specific to Topaz for Total Test. Here is a glossary for your convenience.

    Terminology

    Term Description

    Connection Specifies the location (i.e. IP address) and other properties to connect to the host (LPAR).

    Environment Contains additional information such as Batch, CICS and Db2 settings for the target environment in which the component will execute.

    System Specifies the default source and load libraries to be used to define components. Can also contain additional information for Db2 and/or JCL definitions.

    Component A module that you want to test.

    Categories A way to filter the components list.

  • The Mainframe Software Partner for the Next 50 Years

    5

    Restarting This Script

    At any point should you need to restart this Test Drive script, follow the instructions below:

    Using the Web Interface – You can just start the script from the beginning. There is nothing you need to reset.

    Using the Eclipse Interface – In the Project Explorer pane, select the Functional Test project you want to start over, right click and select Delete. You can then restart the script from the beginning of the Eclipse Interface section.

    FUNCTIONAL AND INTEGRATION TESTING

    Topaz for Total Test supports the functional testing of live load modules on an LPAR in batch and CICS using live data. Programs can be written in COBOL, PL/I or Assembler. Functional tests are defined in a test scenario; and the user can manually enter specify input and expected output data for the linkage section of the module.

    Developers use a test scenario to execute functional tests for live program testing. Test scenario elements can also be used to create a sequence of steps (e.g. set up data in datasets and Db2) before testing programs, execute live programs by providing input data and verify output data; and finally verify data created by the program in Db2 and datasets. This approach can also be used to test complex batch jobs.

  • The Mainframe Software Partner for the Next 50 Years

    6

    Topaz for Total Test – Web Interface

    To get started in Topaz for Total Test, do the following:

    In Topaz, click on “Run➔External Tools➔Chrome” in the menu bar to launch Chrome browser externally. Chrome Opens with multiple tabs (as shown):

    This will display the Login page for Compuware Enterprise Services (CES). Enter your assigned Test Drive ID (i.e. cwezxxx) and your assigned password and click Login.

  • The Mainframe Software Partner for the Next 50 Years

    7

    Click on the “Topaz for Total Test” box (see screen shot below). This will bring you to the Web Interface of Total Test.

    This will display the following page

  • The Mainframe Software Partner for the Next 50 Years

    8

    At the top of the menu on the left-hand side, click on Component repository.

    Next, click on Components.

    NOTE: This screen may look different in your session, as all Test Drive users share a common repository. Your view may contain more or fewer components at any time.

  • The Mainframe Software Partner for the Next 50 Years

    9

    For the purposes of this Test Drive, it is safe to assume that the administrative tasks, such as defining connections between Topaz for Total Test and the Compuware mainframe have been previously completed. Compuware has also pre-defined several sample components for use with this script.

  • The Mainframe Software Partner for the Next 50 Years

    10

    Click on XARISCAL in the list of components.

    Now we can see information about this component and how it was defined to the Topaz for Total Test Functional Test repository, including the System and the Environment.

  • The Mainframe Software Partner for the Next 50 Years

    11

    Scrolling down the component definition you can see that the Main source library and Load library have default values. These were picked up from the System called TEST DRIVE. You can override values picked up from the System definition on this component screen if you wish.

    Scrolling down further we can see the Data structure for this program. There is a field called age and a field called risc. This data structure was extracted from the source code of the program.

  • The Mainframe Software Partner for the Next 50 Years

    12

    Scroll to the top of the page, and in the upper right-hand corner click on Goto Execute.

    The Execute screen has three columns of interest – Value, Expected, and Result. Enter a 2 in the Value column next to the age field, and a 4 in the Expected column next to the risc field. Then click on the green Execute button in the upper right-hand corner.

  • The Mainframe Software Partner for the Next 50 Years

    13

    If the Host Credentials screen appears, enter the TSOID and password that was provided to you and click OK.

    The component is now being executed on the mainframe.

    There is a message in the upper right-hand corner of the screen as well as a green bar across the top that says, “Execution successful”. Additionally, in the result column you can see that the Result value for the risc field matches the Expected value.

  • The Mainframe Software Partner for the Next 50 Years

    14

    If you wish, you can try a second test, entering 20 for the value of age, and 60 for the expected value for risc and clicking Execute.

    Next, we will build and execute a test via the eclipse interface under Topaz Workbench.

  • The Mainframe Software Partner for the Next 50 Years

    15

    Topaz for Total Test – Eclipse Interface via Topaz Workbench

    Click on the Switch windows icon in the upper left-hand corner of the screen.

    Click on the Topaz Workbench window on the right-hand side of your screen.

  • The Mainframe Software Partner for the Next 50 Years

    16

    If the Total Test perspective is not open, click on Compuware and select Total Test.

    NOTE: Your screen may look different than the one above depending upon what other Test Drive scripts you have executed prior to this session.

  • The Mainframe Software Partner for the Next 50 Years

    17

    Click on the Repository tab to make this window active.

    If the “Compuware Enterprise Services Login” window appears, enter your assigned Test Drive ID and password in the appropriate fields. Click OK.

  • The Mainframe Software Partner for the Next 50 Years

    18

    You can click No when this screen appears.

    Your screen should look something like the one shown.

    NOTE: If your repository view is empty, click on the refresh icon (the 2 yellow arrows).

  • The Mainframe Software Partner for the Next 50 Years

    19

    To create a functional test case using the Total Test eclipse interface, we must first create a project. You can store all test cases in a single project if you wish, or you can have multiple projects. The choice is up to you.

    In the Project Explorer pane, right click, click on New and select Project.

  • The Mainframe Software Partner for the Next 50 Years

    20

    Expand the Compuware category and select Topaz for Total Test Project and click Next.

    In the Name field enter “TEST_DRIVE_TESTS”. In the Folder field enter COBOL and click Finish.

  • The Mainframe Software Partner for the Next 50 Years

    21

    In the Project Explorer, expand the TEST_DRIVE_TEST and then the COBOL folder.

    You will see the Scenarios folder that was created under the COBOL folder.

  • The Mainframe Software Partner for the Next 50 Years

    22

    We are going to create a functional test for a CICS/COBOL/Db2 program.

    Click on the COBOL folder to highlight it. In the Repository pane, right click on the component called LGICUS01. Click on “Create Total Test Scenario”.

  • The Mainframe Software Partner for the Next 50 Years

    23

    The Folder and File name fields are populated for us. This is because we had selected the COBOL folder in the Project Explorer view, and by right clicking on the LGICUS01 component in the Repository view. Click Finish.

  • The Mainframe Software Partner for the Next 50 Years

    24

    In the Project Explorer you can expand the Scenarios folder to see we have created two files. The .scenario file will contain the test case details. The .context file will contain execution information. Because we selected the LGICUS01 component from the repository tab it automatically included it as a Functional Test element in our test case.

    This module is a COBOL CICS subroutine that accesses a Db2 table. We are going to build a Db2 query to select rows from a Db2 table to use as input into our functional test case as well as provide expected values for the first and last name fields.

  • The Mainframe Software Partner for the Next 50 Years

    25

    In the Palette window, click on the SQL Select widget and drag it to the LGICUS01.scenario pane and drop it above the Component LGICUS01.

    NOTE: When dragging/dropping widgets from the Palette window to the Test Scenario window, you will see a black line appear as you hover above and/or below the component. With the example above, you will drop the SQL Select widget ABOVE the component.

  • The Mainframe Software Partner for the Next 50 Years

    26

    After dropping the SQLSelect widget a window will open to allow you to enter a SQL statement.

    For our test change the “ID” field to say SELECT. You can enter a description similar to the example shown below if you wish. Then, enter the following SQL Statement: SELECT CUSTOMERNUMBER, FIRSTNAME, LASTNAME FROM GENAPPDB.CUSTOMER. Change the “Max rows” from 20 to 2. Click OK.

  • The Mainframe Software Partner for the Next 50 Years

    27

    Your screen should look like the one below.

  • The Mainframe Software Partner for the Next 50 Years

    28

    Next, click on the Iterate widget in the Palette and drop it between the SQLSelect element and the Functional Test element.

  • The Mainframe Software Partner for the Next 50 Years

    29

    A window will open to allow you to customize the IterateData widget.

    Click in the Reference id field and choose SELECT.

    This is the id we gave to our SQLSelect statement. This tells our test scenario that we want to reference the data returned by the SQL statement.

    Click OK.

  • The Mainframe Software Partner for the Next 50 Years

    30

    This is what your screen should look like after clicking OK.

  • The Mainframe Software Partner for the Next 50 Years

    31

    Left click on the LGICUS01 component and drop it on top of the Iterate line.

    This will make the functional test iterate as many times as there are rows of data being selected by the SQL Select. In our case we are selecting two rows, so the functional test will execute twice.

  • The Mainframe Software Partner for the Next 50 Years

    32

    You screen should look like this.

    Save this functional test case by either clicking on the save icon on the tool bar or by hitting Ctrl+S on your keyboard.

  • The Mainframe Software Partner for the Next 50 Years

    33

    Next, we are going to write expressions to use the data being retrieved from Db2 by our SQL Select statement as both input to our functional test as well as expected results.

    In the Value column next to ca-customer-num, enter the following expression: =SELECT.Row[0].CUSTOMERNUMBER

    This will use the first row from the SELECT element (our SQL Select statement) and the value retrieved for CUSTOMERNUMBER as input to the test. It will read the Db2 table looking for the record with that CUSTOMERNUMBER.

  • The Mainframe Software Partner for the Next 50 Years

    34

    It should look like this:

  • The Mainframe Software Partner for the Next 50 Years

    35

    In the Expected Value column next to ca-first-name, enter the following expression: =SELECT.Row[0].FIRSTNAME

    In the Expected Value column next to ca-last-name, enter the following expression: =SELECT.Row[0].LASTNAME

    This will use the first row from the SELECT element (our SQL Select statement) and the values retrieved for FIRSTNAME and LASTNAME as expected values to validate the test.

    At this point we need to save the changes we have made to the test scenario. You can either click CTL+S to save the scenario or click on the SAVE icon (diskette) on the toolbar to do a save.

  • The Mainframe Software Partner for the Next 50 Years

    36

    To execute this functional test case, click on the green arrow in the upper right-hand corner.

  • The Mainframe Software Partner for the Next 50 Years

    37

    In the Execution Context window, click on the dropdown arrow in the Environment box and select TEST DRIVE – CICS. Click OK.

  • The Mainframe Software Partner for the Next 50 Years

    38

    Enter your Test Drive ID and password that were provided to you in your welcome email. Click OK.

  • The Mainframe Software Partner for the Next 50 Years

    39

    You will see a status bar as the functional test is executing.

    The execution was successful. In the Details window/Table tab you can see the data that was returned from the program execution. We selected 2 rows from our Db2 table to use as input, and the Iterate ran the module twice – once for each row.

  • The Mainframe Software Partner for the Next 50 Years

    40

    Functional Test with Code Coverage

    For batch functional tests we can turn on Xpediter/Code Coverage to see what code has been executed during your test. This section will walk you through creating a test case for a batch COBOL subroutine, turning on code coverage during execution of the test case, and reviewing the code coverage data.

    To start, we are going to create a test case for component CWXTSUBC. Click on the Repository tab to make it active in the bottom pane. Then click on the Scenarios folder in the menu on the left.

  • The Mainframe Software Partner for the Next 50 Years

    41

    Right click on the CWXTSUBC component and select Create Total Test Scenario.

    The folder should be pointing to the Scenarios subfolder, and the file name should default to CWXTSUBC, which is the name of the component we right clicked on. Click Finish.

  • The Mainframe Software Partner for the Next 50 Years

    42

    Click on the Functional Test component in the Test Scenario window to display the Element Properties window to the right.

    Enter the following data under the Value column – M for emp-type and 450000 for sales-amount. Enter 18000 in the Expected Value column for comm-total. Click on the Save icon to save this test scenario.

  • The Mainframe Software Partner for the Next 50 Years

    43

    Click on the green arrow in the upper righ corner to execute this test scenario.

    The Execution context window will appear. (If you forgot to save your test case first and a message appears asking if you want to save, click OK). Click on the Code Coverage tab.

  • The Mainframe Software Partner for the Next 50 Years

    44

    Check the Collect Code Coverage box. Enter CWEZ000.TOPAZ.TTT.REPOSIT for the Repository name. Enter your assigned Test Drive ID (i.e. CWEZXXX) as the System name. Enter EMP-TYPE=M as the Test ID. Click OK.

    The “Clear existing statistics before running the test” option will delete any data from the repository for this System name and Test ID.

    The “Display a report after running the test” option will give you the option to have the Code Coverage report displayed after the test has executed.

  • The Mainframe Software Partner for the Next 50 Years

    45

    The test has been submitted and is executing.

    The test was successful. Because we had turned on Code Coverage and checked the box to display a report after running the test, we see the Confirm Open Perspective dialog. Click Yes.

    NOTE: If you click the “Remember my decision” box the Code Coverage perspective will always be displayed when the test has completed execution.

  • The Mainframe Software Partner for the Next 50 Years

    46

    The Code Coverage perspective is now open and active. The first thing we need to do is create a Report Request. You can close the Cheat Sheets tab if you wish.

  • The Mainframe Software Partner for the Next 50 Years

    47

    We are going to take a look at the annotated listing to get a visual of which lines of code have been executed during our test. Double-click on CWXTSUBC.

  • The Mainframe Software Partner for the Next 50 Years

    48

    Double click on the report tab (CWXTSUBC) to make this full screen.

  • The Mainframe Software Partner for the Next 50 Years

    49

    We can see that the 1000-PROCESS-SALES paragraph is highlighted in red, which means we did not execute this code with our test case.

  • The Mainframe Software Partner for the Next 50 Years

    50

    You can create/execute as many different test cases as you wish to try and reach the level of code coverage required to sign off on this program.

    You are done! As a part of this exercise, you have been able to use Topaz for Total Test to:

    • Execute a batch COBOL functional test via the Topaz for Total Test Functional Test web interface

    • Create a test case in the Topaz for Total Test perspective via Topaz Workbench

    • Executing a COBOL CICS/Db2 functional test in the Topaz for Total Test perspective via Topaz Workbench

    • Collect Code Coverage data during the execution of a functional test

    Congratulations! This completes the Topaz for Total Test Functional Test tutorial for Compuware Test Drive.

    NEXT STEPS

    • Should you wish to restart this Test Drive script, follow the restart instructions at the beginning of this script.

    • For more information about “Mainstreaming the Mainframe” visit our Mainframe DevOps site at https://devops.api.compuware.com/

    • Click on the link below to return to the Compuware Test Drive main page and choose your next road trip!

    • COMPUWARE TEST DRIVE

    https://devops.api.compuware.com/https://compuware.com/test-drive/