Skip to content

Commit 98fbba1

Browse files
authored
Merge pull request #117 from chkware/release-maintenance/2025-JUN-28
Release maintenance of 2025 JUN 28
2 parents 60d8199 + ea122bc commit 98fbba1

File tree

6 files changed

+611
-416
lines changed

6 files changed

+611
-416
lines changed

docs/quick-start.md

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,40 +8,46 @@ Prerequisite: [Setup **CHKware**](/docs/setup) to continue
88

99
:::
1010

11-
### A real business story
11+
### 1. A business story
1212

13-
DummyJSON service a JSON response faker for API. Let's think of a business case based on the [listed APIs](https://dummyjson.com/docs).
13+
DummyJSON service a JSON request / response faker for API. Let's think of a business case based on the [listed APIs](https://dummyjson.com/docs).
1414

15-
#### Business scenario:
15+
#### Business case:
1616

1717
User should be able to add a post on DummyJSON service.
1818

1919
#### Test cases:
2020

21-
Suppose our webapp have a page to add a new post. This page also shows some user information. Let's imagine the API test workflow for this page.
21+
Suppose our web application has a page to add a new post. This page also shows some user information.
22+
23+
Let's assume the API test workflow for this page looks like following:
2224

2325
1. User is able to login. API response have a bearer *access_token*.
2426
2. User is able to get *self* or *me* URL to show user information on page.
2527
3. User is able to create a post using that bearer *access_token*.
2628

27-
### Test implementation
29+
Let's create API test cases for these steps.
30+
31+
### 2. Test implementation
2832

2933
To implement the above test cases we need to be able to fetch an API response. Fetch multiple different APIs in a flow. Let's do in with *CHKware*.
3034

3135
#### Prepare for the project.
3236

33-
- Create a directory in anywhere in your system and give it a meaningful name.
34-
- Now open the console terminal where `chk` command is install. Follow setup steps if it hasn't been done already.
35-
- Go to the directory in console using
37+
- Create a directory called `my-api-project-tests` in anywhere in your system. You can give it any meaningful name.
38+
- Now open the console terminal. Please make sure `chk` command is installed globally. Follow [setup steps](./setup.md) if it hasn't been done already.
39+
- Go to the `my-api-project-tests` directory in console using
40+
3641
```shell
37-
cd [DIRECTORY]
42+
cd path/to/my-api-project-tests
3843
```
3944

4045
#### Login to get bearer *access_token*
4146

42-
- Create a file called `req-login.chk`. File name has no special significance. Open `req-login.chk` file, and add following:
47+
- Create a file called `req-login.chk`.
48+
- Open `req-login.chk` file in your favourite text editor, and add following:
4349

44-
```yaml
50+
```yaml title="path/to/my-api-project-tests/req-login.chk"
4551
---
4652
version: default:http:0.7.2
4753

@@ -61,7 +67,7 @@ expose:
6167
<details>
6268
<summary>Explanation</summary>
6369
64-
This file is called *HTTP specification* or *HTTP spec* file in *CHKware*. This file holds configuration to call an URL.
70+
This file is called *HTTP specification* or *HTTP spec* file in *CHKware*. This file holds configuration to make one HTTP request.
6571
6672
With `request:` node, we define what to request, and with `expose:` section we mention what to return. In this case the HTTP response body that was received.
6773

@@ -72,7 +78,7 @@ expose:
7278

7379
- Create a file called `req-user-me.chk`. File name has no special significance. Open `req-user-me.chk` file, and add following:
7480

75-
```yaml
81+
```yaml title="path/to/my-api-project-tests/req-user-me.chk"
7682
---
7783
version: default:http:0.7.2
7884
@@ -102,7 +108,7 @@ expose:
102108

103109
- Create a file called `req-post-create.chk`. File name has no special significance. Open `req-post-create.chk` file, and add following:
104110

105-
```yaml
111+
```yaml title="path/to/my-api-project-tests/req-post-create.chk"
106112
---
107113
version: default:http:0.7.2
108114
@@ -136,7 +142,7 @@ expose:
136142

137143
- Create a file called `wf-user-post-create.chk`. File name has no special significance. Open `wf-user-post-create.chk` file, and add following:
138144

139-
```yaml
145+
```yaml title="path/to/my-api-project-tests/wf-user-post-create.chk"
140146
---
141147
version: default:workflow:0.8.0
142148

docs/references/assertions.md

Lines changed: 53 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -4,72 +4,80 @@ title: Assertions
44

55
Assertions are integral part of [_Validate specification_](/docs/references/validate-spec).
66

7-
Assertions are used for the validation of specific data point. Asserts are written in _validate specification_.
7+
Assertions are used for the validation of specific data point. Asserts are written in _validate specification. It looks like following:
8+
9+
```yml {6-11}
10+
version: default:validate:0.7.2
11+
12+
data:
13+
code: 200
14+
15+
asserts:
16+
- type: Equal
17+
actual: <% _data.code %>
18+
expected: 200
19+
msg_pass: 'Response was successful'
20+
msg_fail: 'Response was unsuccessful'
21+
22+
- # [assertItem]
23+
```
824

925
## Assert items
1026
_CHKware_ have a collection of built-in assert items. Assertion item object have following components:
1127

12-
- `type` Type of assertion to be executed or the assertion key.
28+
- `type` Type of assertion to be executed or the assertion key. [See here](#assert-types)
1329

1430
- `actual` Actual data point for validation. Variables or data can be used.
1531

1632
- `expected` Expected data point for validation. Variables or data can be used. Most assert item have `expected` alternative to `other`. Both can not exist in same assert item at the same time.
1733

1834
- `other` Other data point for compare. Variables or data can be used. Some assert item have `other` alternative to `expected`. Both can not exist in same assert item at the same time.
1935

20-
- `format` Format of a date. Only supported with [Date assert](#date) items
21-
22-
:::tip
23-
24-
Supports these [format code](https://docs.python.org/3/library/datetime.html#strftime-and-strptime-format-codes).
25-
26-
:::
27-
28-
- `msg_pass` An alternative message to display on success.
29-
30-
:::tip
31-
32-
It is possible to pass formatted string to `msg_pass`. Following values are supported:
33-
34-
- assert_type : Assert item type, e.g: `Str`, `Integer`, `Count`, etc
35-
- type_actual : Type of the actual given on spec file
36-
- type_expected : Type of the expected given on spec file
37-
- value_expected : Value of the expected given on spec file
38-
- value_actual : Value of the actual after cast conversion
39-
- value_actual_given : Value of the actual given on spec file
40-
- value_actual_b4_cast : Value of the actual before cast conversion
41-
42-
E.g: "actual `{type_actual}({value_actual})` is equal to expected `{type_expected}({value_expected})`"
43-
44-
:::
45-
46-
- `msg_fail` An alternative message to display on failure
36+
- `format` Format of a date. Only supported with [`Date` assert](#date) items. Supports these [format code](https://docs.python.org/3/library/datetime.html#strftime-and-strptime-format-codes).
4737

48-
:::tip
38+
- `msg_pass` An alternative message to display on success. It is possible to pass formatted string to `msg_pass`.
4939

50-
It is possible to pass formatted string to `msg_fail`. Following values are supported:
40+
<details>
41+
<summary>Supported values are:</summary>
5142

52-
- assert_type : Assert item type, e.g: `Str`, `Integer`, `Count`, etc
53-
- type_actual : Type of the actual given on spec file
54-
- type_expected : Type of the expected given on spec file
55-
- value_expected : Value of the expected given on spec file
56-
- value_actual : Value of the actual after cast conversion
57-
- value_actual_given : Value of the actual given on spec file
58-
- value_actual_b4_cast : Value of the actual before cast conversion
43+
- assert_type : Assert item type, e.g: `Str`, `Integer`, `Count`, etc
44+
- type_actual : Type of the actual given on spec file
45+
- type_expected : Type of the expected given on spec file
46+
- value_expected : Value of the expected given on spec file
47+
- value_actual : Value of the actual after cast conversion
48+
- value_actual_given : Value of the actual given on spec file
49+
- value_actual_b4_cast : Value of the actual before cast conversion
5950

60-
E.g: "actual `{type_actual}({value_actual})` is not equal to expected `{type_expected}({value_expected})`"
51+
---
52+
E.g: "actual `{type_actual}({value_actual})` is equal to expected `{type_expected}({value_expected})`"
6153

62-
:::
54+
</details>
6355

64-
- `cast_actual_to` Cast data to the type before assertion
56+
- `msg_fail` An alternative message to display on failure. It is possible to pass formatted string to `msg_fail`.
6557

66-
:::tip
58+
<details>
59+
<summary>Supported values are:</summary>
60+
61+
- assert_type : Assert item type, e.g: `Str`, `Integer`, `Count`, etc
62+
- type_actual : Type of the actual given on spec file
63+
- type_expected : Type of the expected given on spec file
64+
- value_expected : Value of the expected given on spec file
65+
- value_actual : Value of the actual after cast conversion
66+
- value_actual_given : Value of the actual given on spec file
67+
- value_actual_b4_cast : Value of the actual before cast conversion
68+
69+
---
70+
E.g: "actual `{type_actual}({value_actual})` is not equal to expected `{type_expected}({value_expected})`"
6771

68-
It is possible to cast type of `actual` value before comparison with `expected` with `cast_actual_to`.
72+
</details>
6973

70-
These types are supported: `int_or_float`, `int`, `float`, `bool`, `none`, `map`, `list`, `str`, `auto`
74+
- `cast_actual_to` Cast data to the type before assertion. It is possible to cast type of `actual` value before comparison with `expected` with variables.
75+
76+
<details>
77+
<summary>Supported values are:</summary>
7178

72-
:::
79+
These types are supported: `int_or_float`, `int`, `float`, `bool`, `none`, `map`, `list`, `str`, `auto`
80+
</details>
7381

7482
<details>
7583
<summary>All supported nodes in assert item</summary>

0 commit comments

Comments
 (0)