You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
10
10
@@ -72,14 +72,15 @@ Use the following steps to create a default configuration for your project:
72
72
{
73
73
"rpgunit": {
74
74
"rucrtrpg": {
75
-
"tgtCcsid": 37,
75
+
"tgtCcsid": "*JOB",
76
76
"dbgView": "*SOURCE",
77
+
"rpgPpOpt": "*LVL2",
77
78
"cOption": [
78
79
"*EVENTF"
79
80
]
80
81
},
81
82
"rucrtcbl": {
82
-
"tgtCcsid": 37,
83
+
"tgtCcsid": "*JOB",
83
84
"dbgView": "*SOURCE",
84
85
"cOption": [
85
86
"*EVENTF"
@@ -96,10 +97,35 @@ Use the following steps to create a default configuration for your project:
96
97
97
98
## Execution Configuration
98
99
99
-
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.
100
+
When it comes time to executing the tests, the extension essentially runs the `RUCALLTST` command provided by RPGUnit. The parameters for this command modify how the tests are executed, such as the order to run the tests and whether to reclaim resources after each test case. These parameters can be configured in the either the VS Code settings or in the `testing.json` configuration file.
101
+
102
+
### VS Code Settings
103
+
104
+
Configuring the execution parameters via the VS Code settings is the suggested option if you prefer to treat these parameters as preferences that will allow each developer to configure for how tests are executed. These settings can be found by going to the extension's settings and searching for **IBM i Testing** (from **Run Order** to **Reclaim Resources**).
100
105
101
106

102
107
108
+
### Configuration File
109
+
110
+
The alternative option is to configure the execution parameters in the `testing.json` configuration file (the same one used for compile command configuration). This is useful if you want to enforce specific execution parameters to be used by all developers working on a project.
111
+
112
+
Here is an example with all execution parameters set in the `testing.json` file:
113
+
114
+
```json
115
+
{
116
+
"rpgunit": {
117
+
"rucalltst": {
118
+
"order": "*API",
119
+
"libl": "*CURRENT",
120
+
"jobD": "*DFT",
121
+
"detail": "*BASIC",
122
+
"output": "*ALLWAYS",
123
+
"rclRsc": "*NO"
124
+
}
125
+
}
126
+
}
127
+
```
128
+
103
129
## Compile, Execution, and Coverage Parameters
104
130
105
131
<Tabs>
@@ -121,7 +147,7 @@ When it comes time to executing the tests, the extension essentially runs the `R
121
147
|`compileOpt`|Pre-Compiler COMPILEOPT |Refer to the `COMPILEOPT` parameter in `CRTSQLRPGI` command help. ||
122
148
|`tgtRls`|Target release |Refer to the `TGTRLS` parameter in `CRTSRVPGM` command help. ||
123
149
|`incDir`|Include directory |Specifies 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. ||
124
-
|`tgtCcsid`|Target CCSID |Specifies the CCSID that the compiler uses to read the source files. |37 |
150
+
|`tgtCcsid`|Target CCSID |Specifies the CCSID that the compiler uses to read the source files. |*JOB|
125
151
|`wrapperCmd`|Wrapper Command |Specifies a custom command to wrap the `RUCRTRPG` command. ||
126
152
</TabItem>
127
153
<TabItemlabel="RUCRTCBL" >
@@ -141,7 +167,7 @@ When it comes time to executing the tests, the extension essentially runs the `R
141
167
|`compileOpt`|Pre-Compiler COMPILEOPT |Refer to the `COMPILEOPT` parameter in `CRTSQLCBLI` command help. ||
142
168
|`tgtRls`|Target release |Refer to the `TGTRLS` parameter in `CRTSRVPGM` command help. ||
143
169
|`incDir`|Include Directory |Specifies 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. ||
144
-
|`tgtCcsid`|Target CCSID |Specifies the CCSID that the compiler uses to read the source files. |37 |
170
+
|`tgtCcsid`|Target CCSID |Specifies the CCSID that the compiler uses to read the source files. |*JOB|
145
171
|`wrapperCmd`|Wrapper Command |Specifies a custom command to wrap the `RUCRTCBL` command. ||
146
172
</TabItem>
147
173
<TabItemlabel="CODECOV" >
@@ -157,41 +183,56 @@ When it comes time to executing the tests, the extension essentially runs the `R
157
183
|Run Order |Specifies the order for running the test procedures. Useful to check that there is no dependencies between test procedures. |*API |
158
184
|Library List |Specifies the library list for executing the specified unit test. |*CURRENT |
159
185
|Job Description |Specifies the name of the job description that is used to set the library list, when the `IBM i Testing: Library List` setting is set to `*JOBD`. `*DFT` can be used here to indicate the library of the unit test suite (service program) is searched for job description `RPGUNIT`. |*DFT |
160
-
|Job Description Library |Specifies the library that is searched for the job description. `*LIBL` can be used here to indicate all libraries in the user and system portions of the job's library list are searched until the first match is found. ||
161
186
|Report Detail |Specifies how detailed the test run report should be. |*BASIC |
162
187
|Create Report |Specifies whether a report is created. |*ALLWAYS |
163
188
|Reclaim Resources |Specifies when to reclaim resources. Resources, such as open files, can be reclaimed after each test case or at the end of the test suite. This option is useful if the test suite calls OPM programs, which do not set the `*INLR` indicator. |*NO |
164
189
</TabItem>
165
190
</Tabs>
166
191
167
-
<Asidetype="note">
168
-
The `wrapperCmd` parameter in the `RUCRTRPG` and `RUCRTCBL` sections are not actual parameters of the RPGUnit commands, but rather are provided by the extension to allow wrappering them. This is primarily used when integrating RPGUnit with other vendor tools.
The `wrapperCmd` parameter in the `RUCRTRPG`/`RUCRTCBL`/`RUCALLTST` specifications are not actual parameters of the RPGUnit commands, but rather are provided by the extension to allow wrappering them. This is primarily used when integrating RPGUnit with other vendor tools.
*[COBOL](https://marketplace.visualstudio.com/items?itemName=bitlang.cobol)*(Optional - Install if writing COBOL unit tests)*
35
35
36
36
### 2. RPGUnit
37
37
38
-
The `RPGUNIT` library must be be installed on your IBM i in order to leverage the framework and assertions that it provides. It can be installed easily via the extension using the steps below which is the recommended approach or manually using the instructions [here](https://irpgunit.sourceforge.io/help/).
38
+
The `RPGUNIT` library ***(`5.1.0-beta.005` minimum)***must be be installed on your IBM i in order to leverage the framework and assertions that it provides. It can be installed easily via the extension using the steps below which is the recommended approach or manually using the instructions [here](https://irpgunit.sourceforge.io/help/).
39
39
40
40
#### Preconditions
41
41
RPGUnit requires OS400 7.5 for the latest features. It can also be installed on 7.4 and 7.3 if the following PTFs have been installed:
Before running any tests, it is recommended that `RPGUNIT.LIB` and `QDEVTOOLS.LIB` are added to your library list to avoid issues with resolving include files. In the case you are working with local test files and are using `iproj.json`, you can add this to your `preUsrlibl` in `iproj.json`. In the case of source members, you can add these libraries via the **User Library List** view in Code for IBM i. You may see the following warnings in the case these libraries are not on your library list:
12
+
13
+

14
+
7
15
## Test Explorer
8
16
9
17
For tests to be discovered by the extension, you must first [connect to an IBM i](../../../quickstart/). Once connected, the extension will automatically discover any RPG/COBOL tests as local files from your workspace or as source members from your library list. These tests will all be listed in the built-in **Test Explorer** view in VS Code (look for the beaker icon).
@@ -14,9 +22,9 @@ From here you can hover on any test case, test suite, folder, library, or source
14
22
15
23
<Steps>
16
24
1.**Deployment *(Local Files Only)***: The contents of your workspace folder will be deployed to a directory in the IFS. The default deployment directory suggested will be of the following format: `/home/<user>/builds/<workspace-folder>/`. This is the same deployment process that takes place when you compile any local files via Code for IBM i.
17
-
2.**Read Test Configuration**: To customize the parameters used to compile your tests, a global and directory specific test configuration will be read. Learn more about this in the [Test Configuration](../configuring/#test-configuration) section.
18
-
3.**Compilation**: Given the test configuration and tests selected for execution, the tests will be compiled via the `RUCRTRPG` or `RUCRTCLB` command. This step will be skipped for tests which have had no change since the last compilation.
19
-
4.**Execution**: The compiled test program will be executed via the `RUCALLTST` command. The parameters for this command are configured as VS Code settings. Again, learn more about this in the [Execution Configuration](../configuring/#execution-configuration) section.
25
+
2.**Read Compile Configuration**: To customize the parameters used to compile your tests, a global and directory specific test configuration file will be read. Learn more about this in the [Compile Configuration](../configuring/#compile-configuration) section.
26
+
3.**Compilation**: Given the compile configuration and tests selected for execution, the tests will be compiled via the `RUCRTRPG` or `RUCRTCLB` command. This step will be skipped for tests which have had no change since the last compilation.
27
+
4.**Execution**: The compiled test program will be executed via the `RUCALLTST` command. The parameters for this command are configured in the VS Code settings or the test configuration file. Learn more about this in the [Execution Configuration](../configuring/#execution-configuration) section.
Copy file name to clipboardExpand all lines: src/content/docs/developing/testing/writing.mdx
+12Lines changed: 12 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -49,6 +49,18 @@ After selecting an option, a test suite will be created if it does not already e
49
49
50
50

51
51
52
+
### Test Stub Preferences
53
+
54
+
There are various preferences that can be used to configure how the test stubs are generated. To access these preferences, go to the extension's settings and search for **Test Stub Preferences**.
One notable preference is the **Show Test Stub Preview** which controls whether to show a preview of the test stub before adding it to the file or source member. Once this preference is enabled, the **Refactor Preview** view will be populated with a set of edits to insert the control options & directives, includes, prototypes, and the test cases. You will need to first select the checkboxes next to the items you want to insert and then click on any item to bring up a preview of the code in the editor. Once you are satisfied with the preview, you can click the **Apply** button to insert the code into your file or source member.
61
+
62
+

63
+
52
64
## API Reference
53
65
54
66
In order to use the APIs provided by RPGUnit, you need to add the `TESTCASE` copybook to your test suite:
0 commit comments