Skip to content

Commit 27692c4

Browse files
committed
docs: Write Tests
1 parent c496a65 commit 27692c4

2 files changed

Lines changed: 120 additions & 173 deletions

File tree

docs/run-and-configure.mdx

Lines changed: 41 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,47 @@ This chapter covers everything that happens when a test suite is executed — ho
1313

1414
---
1515

16+
17+
## Show a single group
18+
19+
```bash
20+
php vendor/bin/unitary --show=448b06d9127fbca608168e769acd3c7c1
21+
```
22+
23+
#### Response
24+
25+
![Unitary CLI response](https://wazabii.se/github-assets/unitary/unitary-cli-show.png)
26+
27+
---
28+
29+
## Configure test groups
30+
Every individual groups can define their own configuration using TestConfig. This allows naming, skipping, or scoping tests directly in code without affecting the rest of the suite.
31+
32+
33+
```php
34+
$config = TestConfig::make()->withName("unitary")->withSkip();
35+
36+
group($config->withSubject("Example API Request"), function(TestCase $case) {
37+
38+
});
39+
40+
group($config->withSubject("Test mocking library"), function(TestCase $case) {
41+
42+
});
43+
```
44+
45+
#### Execute
46+
47+
```bash
48+
php vendor/bin/unitary --show=unitary
49+
```
50+
51+
#### Response
52+
53+
![Unitary CLI response](https://wazabii.se/github-assets/unitary/unitary-cli-state-grouped.png)
54+
55+
---
56+
1657
## Running tests (CLI)
1758

1859
The Unitary CLI is the fastest way to execute and inspect tests.
@@ -104,39 +145,6 @@ They share the same names, accepted types, and default values.
104145

105146
---
106147

107-
## Per-group configuration
108-
109-
While CLI flags and the config file define global behavior, individual groups can define their own configuration using `TestConfig`.
110-
This allows naming, skipping, or scoping tests directly in code without affecting the rest of the suite.
111-
112-
```php
113-
use MaplePHP\Unitary\{TestConfig, TestCase, Expect};
114-
115-
$config = TestConfig::make("Checkout API")
116-
->withName("checkout")
117-
->withSkip(); // temporarily skip this group
118-
119-
group($config, function (TestCase $case) {
120-
// ...
121-
});
122-
```
123-
124-
Configurations are immutable, so you can derive variations without side effects:
125-
126-
```php
127-
group($config->withSubject("Refund flow"), function (TestCase $case) {
128-
// ...
129-
});
130-
```
131-
132-
Named groups can always be executed in isolation:
133-
134-
```bash
135-
php vendor/bin/unitary --show=checkout
136-
```
137-
138-
---
139-
140148
## Layer interaction
141149

142150
Unitary merges configuration from all sources in a fixed order:

0 commit comments

Comments
 (0)