Skip to content

Configuring Tests

Test Configuration

The process of defining how to compile your tests is greatly simplified using a configuration file called testing.json. This file allows you to specify the parameters for the RPGUnit compile commands (RUCRTRPG and RUCRTCBL) and the code coverage command (CODECOV) in JSON format. The scope in which these parameters are applied is determined by the location of the testing.json file and depends on whether you are working with local files or source members.

Local Files

The following hierarchy is used to determine the configuration for local files:

  • <directory>/testing.json: This is a directory level configuration file that will apply to all tests in that directory.
  • .vscode/testing.json: This is a global configuration file that will apply to all tests in that project. Parameters not set at the directory level will be inherited from this global configuration.

Shown below is an example of a project structure with the testing.json file at the global and directory level:

  • Directorymy-project
    • Directory.vscode
      • testing.json Global configuration
    • Directoryqsqlsrc
      • employee.sql
    • Directoryqrpglesrc
      • utilsA.rpgle
      • utilsB.rpgle
      • employee.rpgle
    • Directoryqtestsrc
      • Directoryutils
        • testing.json Directory level configuration
        • utilsA.test.rpgle
        • utilsB.test.rpgle
      • employee.test.rpgle

Source Members

The following hierarchy is used to determine the configuration for source members:

  • <sourceFile>/testing.json: This is a source file level configuration file that will apply to all tests in that source file.
  • VSCODE.FILE/testing.json: This is a global configuration file that will apply to all tests in that library. Parameters not set at the source file level will be inherited from this global configuration.

Shown below is an example of a project structure with the testing.json file at the global and source file level:

  • DirectoryMYUSER.LIB
    • DirectoryVSCODE.FILE
      • TESTING.JSON Global configuration
    • DirectoryQSQLSRC.FILE
      • EMPLOYEE.SQL
    • DirectoryQRPGLESRC.FILE
      • EMPLOYEE.RPGLE
      • UTILSA.RPGLE
      • UTILSB.RPGLE
    • DirectoryQTESTSRC.FILE
      • EMPLOYEE_T.RPGLE
    • DirectoryUTILTESTS.FILE
      • TESTING.JSON Source file level configuration
      • UTILSA_T.RPGLE
      • UTILSB_T.RPGLE

Default Configuration

Use the following steps to create a default configuration for your project:

  1. Create a testing.json file or source member in the desired location.
  2. Press Ctrl+Space and select the IBM i Testing Configuration option to generate the default configuration:
    {
    "rpgunit": {
    "rucrtrpg": {
    "tgtCcsid": 37,
    "dbgView": "*SOURCE",
    "cOption": [
    "*EVENTF"
    ]
    },
    "rucrtcbl": {
    "tgtCcsid": 37,
    "dbgView": "*SOURCE",
    "cOption": [
    "*EVENTF"
    ]
    }
    },
    "codecov": {
    "module": []
    }
    }
  3. Use Ctrl+Space within any of the commands to see the available parameters and their descriptions.

Execution Configuration

When it comes time to executing the tests, the extension essentially runs the RUCALLTST command provided by RPGUnit. The parameters for this command are configured in the VS Code settings.

Compile, Execution, and Coverage Parameters

ParameterNameDescriptionDefault
textText descriptionAllows you to enter text that briefly describes the RPGUnit test case and its function.
cOptionCompile optionsRefer to the OPTION parameter in CRTRPGMOD command help.*EVENTF
dbgViewDebugging viewsRefer to the DBGVIEW parameter in CRTRPGMOD command help.*SOURCE
bndSrvPgmBind service programRefer to the BNDSRVPGM parameter in CRTSRVPGM command help.
bndDirBinding directoryRefer to the BNDDIR parameter in CRTSRVPGM command help.
bOptionBinding optionsRefer to the OPTION parameter in CRTSRVPGM command help.
defineDefine condition namesSpecifies condition names that are defined before the compilation begins. Using the parameter DEFINE(condition-name) is equivalent to coding the /DEFINE condition-name directive on the first line of the source file.
dltSplfDelete spooled filesSpecifies if all spooled files (compile listing) created by the object creations commands are deleted on success.
actGrpActivation groupRefer to the ACTGRP parameter in CRTSRVPGM command help.
moduleModuleRefer to the MODULE parameter in CRTSRVPGM command help.
rpgPpOptPre-compiler RPGPPOPTRefer to the RPGPPOPT parameter in CRTSRVPGM command.*LVL2
pOptionPre-compiler OPTIONSRefer to the OPTION parameter in CRTSQLRPGI command help.
compileOptPre-Compiler COMPILEOPTRefer to the COMPILEOPT parameter in CRTSQLRPGI command help.
tgtRlsTarget releaseRefer to the TGTRLS parameter in CRTSRVPGM command help.
incDirInclude directorySpecifies one or more directories to add to the search path used by the compiler to find copy files. The compiler will search the directories specified here if the copy files in the source program can not be resolved.
tgtCcsidTarget CCSIDSpecifies the CCSID that the compiler uses to read the source files.37
wrapperCmdWrapper CommandSpecifies a custom command to wrap the RUCRTRPG command.