Skip to content

Commit 0dcf35a

Browse files
authored
Merge pull request #69 from codefori/feature/improve-test-docs
Document library list setup, execution configuration, test stub preferences
2 parents cd6e83f + 92a1957 commit 0dcf35a

File tree

9 files changed

+106
-45
lines changed

9 files changed

+106
-45
lines changed

.astro/astro/content.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -589,5 +589,5 @@ declare module 'astro:content' {
589589

590590
type AnyEntryMap = ContentEntryMap & DataEntryMap;
591591

592-
export type ContentConfig = typeof import("../../src/content/config.js");
592+
export type ContentConfig = typeof import("./../../src/content/config.js");
593593
}

.astro/settings.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
22
"_variables": {
3-
"lastUpdateCheck": 1750695278030
3+
"lastUpdateCheck": 1752178270354
44
}
55
}
Loading
Loading
Loading

src/content/docs/developing/testing/configuring.mdx

Lines changed: 79 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ title: Configuring Tests
44

55
import { Aside, CardGrid, Card, Tabs, TabItem, FileTree, Steps } from '@astrojs/starlight/components';
66

7-
## Test Configuration
7+
## Compile Configuration
88

99
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.
1010

@@ -72,14 +72,15 @@ Use the following steps to create a default configuration for your project:
7272
{
7373
"rpgunit": {
7474
"rucrtrpg": {
75-
"tgtCcsid": 37,
75+
"tgtCcsid": "*JOB",
7676
"dbgView": "*SOURCE",
77+
"rpgPpOpt": "*LVL2",
7778
"cOption": [
7879
"*EVENTF"
7980
]
8081
},
8182
"rucrtcbl": {
82-
"tgtCcsid": 37,
83+
"tgtCcsid": "*JOB",
8384
"dbgView": "*SOURCE",
8485
"cOption": [
8586
"*EVENTF"
@@ -96,10 +97,35 @@ Use the following steps to create a default configuration for your project:
9697

9798
## Execution Configuration
9899

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**).
100105

101106
![](Testing_ExecutionConfiguration.png)
102107

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+
103129
## Compile, Execution, and Coverage Parameters
104130

105131
<Tabs>
@@ -121,7 +147,7 @@ When it comes time to executing the tests, the extension essentially runs the `R
121147
|`compileOpt` |Pre-Compiler COMPILEOPT |Refer to the `COMPILEOPT` parameter in `CRTSQLRPGI` command help. | |
122148
|`tgtRls` |Target release |Refer to the `TGTRLS` parameter in `CRTSRVPGM` command help. | |
123149
|`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 |
125151
|`wrapperCmd` |Wrapper Command |Specifies a custom command to wrap the `RUCRTRPG` command. | |
126152
</TabItem>
127153
<TabItem label="RUCRTCBL" >
@@ -141,7 +167,7 @@ When it comes time to executing the tests, the extension essentially runs the `R
141167
|`compileOpt` |Pre-Compiler COMPILEOPT |Refer to the `COMPILEOPT` parameter in `CRTSQLCBLI` command help. | |
142168
|`tgtRls` |Target release |Refer to the `TGTRLS` parameter in `CRTSRVPGM` command help. | |
143169
|`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 |
145171
|`wrapperCmd` |Wrapper Command |Specifies a custom command to wrap the `RUCRTCBL` command. | |
146172
</TabItem>
147173
<TabItem label="CODECOV" >
@@ -157,41 +183,56 @@ When it comes time to executing the tests, the extension essentially runs the `R
157183
|Run Order |Specifies the order for running the test procedures. Useful to check that there is no dependencies between test procedures. |*API |
158184
|Library List |Specifies the library list for executing the specified unit test. |*CURRENT |
159185
|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. | |
161186
|Report Detail |Specifies how detailed the test run report should be. |*BASIC |
162187
|Create Report |Specifies whether a report is created. |*ALLWAYS |
163188
|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 |
164189
</TabItem>
165190
</Tabs>
166191

167-
<Aside type="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.
169-
170-
**Example `testing.json` configuration**:
171-
```json
172-
{
173-
"rpgunit": {
174-
"rucrtrpg": {
175-
"tgtCcsid": 37,
176-
"dbgView": "*SOURCE",
177-
"cOption": [
178-
"*EVENTF"
179-
],
180-
"wrapperCmd": {
181-
"cmd": "MYLIB/MYCMD TSTCMD",
182-
"params": {
183-
"desc": "My description"
184-
}
185-
}
186-
}
187-
}
188-
}
189-
```
190-
**Resolved command**:
191-
```
192-
MYLIB/MYCMD TSTCMD(RPGUNIT/RUCRTRPG TSTPGM(MYUSER/TEMPDET)
193-
SRCSTMF('/home/MYUSER/builds/ibmi-company_system/qtestsrc/empdet.test.sqlrpgle')
194-
TGTCCSID(37) DBGVIEW(*SOURCE) COPTION(*EVENTF) RPGPPOPT(*LVL2)
195-
INCDIR('''/home/MYUSER/builds/ibmi-company_system''')) DESC('My description')
196-
```
197-
</Aside>
192+
<Aside type="note">
193+
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.
194+
195+
**Example `testing.json` configuration**:
196+
```json
197+
{
198+
"rpgunit": {
199+
"rucrtrpg": {
200+
"tgtCcsid": "*JOB",
201+
"dbgView": "*SOURCE",
202+
"cOption": [
203+
"*EVENTF"
204+
],
205+
"wrapperCmd": {
206+
"cmd": "MYLIB/MYCMD TSTCMD",
207+
"params": {
208+
"desc": "My description"
209+
}
210+
}
211+
},
212+
"rucalltst": {
213+
"wrapperCmd": {
214+
"cmd": "MYLIB/MYCMD CALLCMD",
215+
"params": {
216+
"desc": "My description"
217+
}
218+
}
219+
}
220+
}
221+
}
222+
```
223+
**Resolved compile command**:
224+
```js
225+
MYLIB/MYCMD TSTCMD(RPGUNIT/RUCRTRPG TSTPGM(MYUSER/TEMPDET)
226+
SRCSTMF('/home/MYUSER/builds/ibmi-company_system/qtestsrc/empdet.test.sqlrpgle')
227+
TGTCCSID(*JOB) DBGVIEW(*SOURCE) COPTION(*EVENTF) RPGPPOPT(*LVL2)
228+
INCDIR('''/home/MYUSER/builds/ibmi-company_system''')) DESC('My description')
229+
```
230+
231+
**Resolved execution command**:
232+
```js
233+
MYLIB/MYCMD CALLCMD(RPGUNIT/RUCALLTST TSTPGM(MYUSER/TEMPDET) ORDER(*REVERSE)
234+
DETAIL(*ALL) OUTPUT(*ALLWAYS) LIBL(*CURRENT) JOBD(*DFT) RCLRSC(*NO)
235+
XMLSTMF('/tmp/testing/vscode-ibmi-testing/RPGUNIT/TEMPDET_1751646914682.xml'))
236+
DESC('My description')
237+
```
238+
</Aside>

src/content/docs/developing/testing/overview.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,12 @@ The [IBM i Testing](https://marketplace.visualstudio.com/items?itemName=IBM.vsco
3030
The following extensions can be installed from the Visual Studio Code Marketplace or Open VSX Registry:
3131
* [IBM i Testing](https://marketplace.visualstudio.com/items?itemName=IBM.vscode-ibmi-testing) ***(Required)***
3232
* [Code for IBM i](https://marketplace.visualstudio.com/items?itemName=HalcyonTechLtd.code-for-ibmi) ***(Required - `2.16.0` minimum)***
33-
* [RPGLE](https://marketplace.visualstudio.com/items?itemName=HalcyonTechLtd.vscode-rpgle) ***(Required - `0.30.0` minimum)***
33+
* [RPGLE](https://marketplace.visualstudio.com/items?itemName=HalcyonTechLtd.vscode-rpgle) ***(Required - `0.31.0` minimum)***
3434
* [COBOL](https://marketplace.visualstudio.com/items?itemName=bitlang.cobol) *(Optional - Install if writing COBOL unit tests)*
3535

3636
### 2. RPGUnit
3737

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/).
3939

4040
#### Preconditions
4141
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:

src/content/docs/developing/testing/running.mdx

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,14 @@ title: Running Tests
44

55
import { Aside, CardGrid, Card, Steps } from '@astrojs/starlight/components';
66

7+
## Setup
8+
9+
### Library List
10+
11+
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+
![](Testing_LibraryValidation.png)
14+
715
## Test Explorer
816

917
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
1422

1523
<Steps>
1624
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.
2028
</Steps>
2129

2230
<Aside type="note">

src/content/docs/developing/testing/writing.mdx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,18 @@ After selecting an option, a test suite will be created if it does not already e
4949

5050
![Generated Test Stub](Testing_GeneratedTestStub.png)
5151

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**.
55+
56+
![Test Stub Preferences](Testing_TestStubPreferences.png)
57+
58+
### Test Stub Preview
59+
60+
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+
![Test Stub Preview](Testing_TestStubPreview.png)
63+
5264
## API Reference
5365

5466
In order to use the APIs provided by RPGUnit, you need to add the `TESTCASE` copybook to your test suite:

0 commit comments

Comments
 (0)