Running code coverage on interactive applications

Running code coverage provides insight into how well your test cases are exercising your IBM i applications by reporting results showing the percentage of lines in your code run by a test case as well as line by line coverage details. You can run code coverage for any IBM i application that you can debug.

Procedure

  1. Compile your program with the source debug option.
    Note:
    • You need to use one of the DBGVIEW(*ALL), DBGVIEW(*SOURCE), or DBGVIEW(*LIST) options.
    • Compiler optimization can affect the report of lines covered. For the most accurate results, compile with OPTIMIZE(*NONE).
    • If portions of the application do not have debug information, only those portions of the application with debug information are included in the code coverage report.
  2. Start the RSE server.
    1. Open a 5250 terminal and enter the STRRSESVR command and press F4.
      Enter STRRSESVR command
    2. Configure the command parameters. Press F10 to see the parameter fields available for the STRRSESVR command.
      Connection Name
      Enter the name for the RSE connection that you have in the IDE
      Remote Location name
      Enter the hostname of the computer that the IDE is running on.
      Configure the command parameters
    3. Press Enter to start the server.
  3. Browse to your program under your connection in Remote Systems Explorer. If you want, you can create filters or add library list entries to facilitate finding your programs.
    Browse to your program
  4. Create a code coverage configuration for an interactive program. Right-click the program and select Code Coverage (Prompt) > Interactive
    Launch code coverage in interactive mode
    A compiled code coverage configuration is created and opened in the Edit configuration and launch dialog.
    Code coverage configuration is opened
    Note: An alternative method to launch code coverage is right-click your program and select Code Coverage As > Interactive. In this case, a configuration is created and the code coverage session is started without opening the Edit configuration and launch dialog. If your program is simple and does not require any additional set up such as adding called programs, this can be a convenient method for starting code coverage.
  5. Add any programs or service programs that are called by your main program. Under the What To Analyze tab, click the Add button to add additional called programs.
    Add called programs
    Called programs after they are added. The main program is selected.
    Called programs added. Main program selected.
  6. Edit the configuration as necessary. For example, under What to Analyze, you can specify the debug view used for analysis. Under How To Start, you can change the command used to start the application. Under Code Coverage, you can specify details such as whether coverage is on the Line or Procedure level. For more information about configurations, see Editing code coverage configurations.
  7. Click the Coverage button to start the code coverage session.
    Click Coverage button
    • The status bar at the bottom of the IDE displays the message Running code coverage for PROGRAM_NAME. Where PROGRAM_NAME is the name of your program.
      Running code coverage message in status bar
    • The program opens in the 5250 terminal and is ready for running tests.
      5250 running program
  8. Interact with your program following your test procedures.
  9. Exit your program in the terminal. After you exit your program, a workbench report is opened and an item summarizing the coverage is added to the Code Coverage Results view.
    Code coverage results

Feedback