You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+33-7Lines changed: 33 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -19,10 +19,9 @@ pip install pytest-api-cov
19
19
20
20
### Basic Usage
21
21
22
-
For most projects, no configuration is needed:
22
+
For most projects, no configuration is needed, just add the flag to your pytest command:
23
23
24
24
```bash
25
-
# Just add the flag to your pytest command
26
25
pytest --api-cov-report
27
26
```
28
27
@@ -32,9 +31,10 @@ Discovery in this plugin is client-based: the plugin extracts the application in
32
31
33
32
How discovery works (in order):
34
33
35
-
1. If you configure one or more candidate client fixture names (see configuration below), the plugin will try each in order and wrap the first matching fixture it finds.
36
-
2. If no configured client fixture is found, the plugin will look for a standard `app` fixture and use that to create a tracked client.
37
-
3. If neither a client fixture nor an `app` fixture is available (or the plugin cannot extract an app from the client), coverage tracking will be skipped and a helpful message is shown.
34
+
1.**OpenAPI Spec**: If an OpenAPI spec file is configured (via CLI or config), endpoints are discovered directly from the spec. This takes precedence over app-based discovery.
35
+
2.**Client Fixtures**: If no spec is provided, the plugin looks for configured client fixtures and extracts the app from them.
36
+
3.**App Fixture**: If no client fixture is found, the plugin looks for a standard `app` fixture.
37
+
4.**Skip**: If none of the above are found, coverage tracking is skipped.
You can use an OpenAPI specification file (JSON or YAML) as the source of truth for API endpoints. This is useful if your app structure makes automatic discovery difficult, or if you want to ensure coverage against a defined contract.
- App-based discovery is skipped (unless the spec yields no endpoints).
142
+
- Coverage is calculated against the endpoints defined in the spec.
143
+
121
144
## HTTP Method-Aware Coverage
122
145
123
146
By default, pytest-api-cov tracks coverage for **each HTTP method separately**. This means `GET /users` and `POST /users` are treated as different endpoints for coverage purposes.
@@ -355,11 +378,14 @@ pytest --api-cov-report -vv
355
378
356
379
# Group HTTP methods by endpoint (legacy behavior)
0 commit comments