Skip to content

Commit e7113c0

Browse files
committed
docs(readme): add console_output parameter documentation
Document the console_output parameter and OPENAPI_CONSOLE_OUTPUT environment variable. Add output examples for all three modes (default, all, uncovered_only) and a GitHub Actions CI example. Refs #27
1 parent b2cfabc commit e7113c0

1 file changed

Lines changed: 65 additions & 1 deletion

File tree

README.md

Lines changed: 65 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ Add the coverage extension to your `phpunit.xml`:
6262
| `strip_prefixes` | No | `[]` | Comma-separated prefixes to strip from request paths (e.g., `/api`) |
6363
| `specs` | No | `front` | Comma-separated spec names for coverage tracking |
6464
| `output_file` | No || File path to write Markdown coverage report (relative paths resolve from `getcwd()`) |
65+
| `console_output` | No | `default` | Console output mode: `default`, `all`, or `uncovered_only` (overridden by `OPENAPI_CONSOLE_OUTPUT` env var) |
6566

6667
*Not required if you call `OpenApiSpecLoader::configure()` manually.
6768

@@ -163,7 +164,11 @@ For Laravel, set the `max_errors` key in `config/openapi-contract-testing.php`.
163164

164165
## Coverage Report
165166

166-
After running tests, the PHPUnit extension prints a coverage report:
167+
After running tests, the PHPUnit extension prints a coverage report. The output format is controlled by the `console_output` parameter (or `OPENAPI_CONSOLE_OUTPUT` environment variable).
168+
169+
### `default` mode (default)
170+
171+
Shows covered endpoints individually and uncovered as a count:
167172

168173
```
169174
OpenAPI Contract Test Coverage
@@ -179,6 +184,56 @@ Covered:
179184
Uncovered: 41 endpoints
180185
```
181186

187+
### `all` mode
188+
189+
Shows both covered and uncovered endpoints individually:
190+
191+
```
192+
OpenAPI Contract Test Coverage
193+
==================================================
194+
195+
[front] 12/45 endpoints (26.7%)
196+
--------------------------------------------------
197+
Covered:
198+
✓ GET /v1/pets
199+
✓ POST /v1/pets
200+
✓ GET /v1/pets/{petId}
201+
✓ DELETE /v1/pets/{petId}
202+
Uncovered:
203+
✗ PUT /v1/pets/{petId}
204+
✗ GET /v1/owners
205+
...
206+
```
207+
208+
### `uncovered_only` mode
209+
210+
Shows uncovered endpoints individually and covered as a count — useful for large APIs where you want to focus on missing coverage:
211+
212+
```
213+
OpenAPI Contract Test Coverage
214+
==================================================
215+
216+
[front] 12/45 endpoints (26.7%)
217+
--------------------------------------------------
218+
Covered: 12 endpoints
219+
Uncovered:
220+
✗ PUT /v1/pets/{petId}
221+
✗ GET /v1/owners
222+
...
223+
```
224+
225+
You can set the mode via `phpunit.xml`:
226+
227+
```xml
228+
<parameter name="console_output" value="uncovered_only"/>
229+
```
230+
231+
Or via environment variable (takes priority over `phpunit.xml`):
232+
233+
```bash
234+
OPENAPI_CONSOLE_OUTPUT=uncovered_only vendor/bin/phpunit
235+
```
236+
182237
## CI Integration
183238

184239
### GitHub Actions Step Summary
@@ -201,6 +256,15 @@ Use the `output_file` parameter to write a Markdown report to a file. This is us
201256
</extensions>
202257
```
203258

259+
You can also use the `OPENAPI_CONSOLE_OUTPUT` environment variable in CI to show uncovered endpoints in the job log:
260+
261+
```yaml
262+
- name: Run tests (show uncovered endpoints)
263+
run: vendor/bin/phpunit
264+
env:
265+
OPENAPI_CONSOLE_OUTPUT: uncovered_only
266+
```
267+
204268
Example GitHub Actions workflow step to post the report as a PR comment:
205269
206270
```yaml

0 commit comments

Comments
 (0)