Skip to content

Commit d8ae9a8

Browse files
Add page on writing tests
Signed-off-by: Sanjula Ganepola <Sanjula.Ganepola@ibm.com>
1 parent 86cd14e commit d8ae9a8

File tree

3 files changed

+125
-1
lines changed

3 files changed

+125
-1
lines changed
180 KB
Loading

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
title: Overview
33
---
44

5-
import { Aside, CardGrid, Card, Tabs, TabItem } from '@astrojs/starlight/components';
5+
import { Aside, CardGrid, Card } from '@astrojs/starlight/components';
66

77
<img src="https://github.com/IBM/vscode-ibmi-testing/blob/main/icon.png?raw=true" align="right" width="256" height="256" />
88

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
---
2+
title: Writing Tests
3+
---
4+
5+
import { Aside, CardGrid, Card, Tabs, TabItem } from '@astrojs/starlight/components';
6+
7+
## Naming Conventions
8+
9+
### Test Cases
10+
11+
In RPGUnit, a test case is an exported procedures that starts with the name `test`. This also means that you should not export procedures starting with `test` if they are not intended to be a test case.
12+
13+
**Example test cases:**
14+
* `test_getEmployeeDetail`
15+
* `test_getDeptDetail`
16+
* `testIsPalindrome`
17+
* `testFactorial`
18+
19+
### Test Suites
20+
21+
A test suite consists of one or more test cases in a file or source member. This test suite will be compiled into a service program in order to run the test cases. Although RPGUnit itself does not enforce an specific naming convention for test suites, the `IBM i Testing` extension does based on whether you are working on local files on your PC or source members on the IBM i.
22+
23+
* **Local Files**: The file must end in `.test.rpgle`, `.test.sqlrpgle`, `.test.cblle`, or `.test.sqlcblle` in order to be detected by the extension. The file can be put in any directory.
24+
* **Source Members**: Source members can be put in any source file, but it is recommended to store them in a source file named `QTESTSRC`. By default this is where the extension will look for test suites in your library list. You can configure the extension to search other source files by going to the extension's settings and searching for the **Test Source Files** setting.
25+
![Test Source Files](Testing_TestSourceFiles.png)
26+
27+
**Example test suites:**
28+
* Local Files
29+
* `employee.test.rpgle`
30+
* `department.test.rpgle`
31+
* `string.test.rpgle`
32+
* `math.test.rpgle`
33+
* Source Members
34+
* `QTESTSRC` source file with members:
35+
* `EMPLOYEE.RPGLE`
36+
* `DEPARTMENT.RPGLE`
37+
* `STRING.RPGLE`
38+
* `MATH.RPGLE`
39+
40+
## Assertions and Utilities
41+
42+
In order to use RPGUnit procedures you need to add the `TESTCASE` copybook to your test suite:
43+
44+
```rpgle
45+
/include qinclude,TESTCASE
46+
```
47+
48+
**Assertions:**
49+
50+
<Tabs>
51+
<TabItem label="aEqual" >
52+
TODO: Add spec here
53+
</TabItem>
54+
<TabItem label="iEqual" >
55+
TODO: Add spec here
56+
</TabItem>
57+
<TabItem label="nEqual" >
58+
TODO: Add spec here
59+
</TabItem>
60+
<TabItem label="assert" >
61+
TODO: Add spec here
62+
</TabItem>
63+
<TabItem label="fail" >
64+
TODO: Add spec here
65+
</TabItem>
66+
<TabItem label="assertJobLogContains" >
67+
TODO: Add spec here
68+
</TabItem>
69+
<TabItem label="assertMessageQueueContains" >
70+
TODO: Add spec here
71+
</TabItem>
72+
</Tabs>
73+
74+
**Utilities:**
75+
76+
<Tabs>
77+
<TabItem label="CLRPFM" >
78+
TODO: Add spec here
79+
</TabItem>
80+
<TabItem label="RCLACTGRP" >
81+
TODO: Add spec here
82+
</TabItem>
83+
<TabItem label="runCmd" >
84+
TODO: Add spec here
85+
</TabItem>
86+
<TabItem label="getMonitoredMessage" >
87+
TODO: Add spec here
88+
</TabItem>
89+
<TabItem label="waitSeconds" >
90+
TODO: Add spec here
91+
</TabItem>
92+
<TabItem label="displayStatusMessage" >
93+
TODO: Add spec here
94+
</TabItem>
95+
</Tabs>
96+
97+
## Setup and Teardown
98+
99+
<Tabs>
100+
<TabItem label="setUpSuite" >
101+
TODO: Add spec here
102+
</TabItem>
103+
<TabItem label="setUp" >
104+
TODO: Add spec here
105+
</TabItem>
106+
<TabItem label="tearDown" >
107+
TODO: Add spec here
108+
</TabItem>
109+
<TabItem label="tearDownSuite" >
110+
TODO: Add spec here
111+
</TabItem>
112+
</Tabs>
113+
114+
## Generating Stubs
115+
116+
## Example Test Suites
117+
118+
To get started with some sample tests, check out these examples:
119+
* [ibmi-company_system](https://github.com/IBM/ibmi-company_system/tree/main/qtestsrc)
120+
* RPGUnit [templates](https://github.com/tools-400/irpgunit/tree/main/host/iRPGUnit/QTEMPLATE) and [self tests](https://github.com/tools-400/irpgunit/tree/main/host/iRPGUnit/QTESTCASES)
121+
122+
<Aside type="tip">
123+
If you have example tests that you would like to share with the community, please open a pull request [here](https://github.com/codefori/docs) to add them to this page.
124+
</Aside>

0 commit comments

Comments
 (0)