Skip to content

Commit 042189b

Browse files
committed
#703 improve docs and code clarity
1 parent 86d3c86 commit 042189b

3 files changed

Lines changed: 23 additions & 1 deletion

File tree

docs/testing.md

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ deployment.
189189
In order to use `harness-test` install the library with
190190

191191
```
192-
pip install -r requirements-test.txt
192+
pip install -e tools/cloudharness-test
193193
```
194194
195195
In order to run tests against an existing deployment based on a domain (say, my.domain), run:
@@ -205,6 +205,25 @@ If you want to run the deployment locally and then run the tests, can use skaffo
205205
1. Wait the deployment to settle
206206
1. Run `harness-test PATHS`
207207
208+
### Tests development
209+
The `harness-test` client is useful while developing and tweaking the tests.
210+
In that case it's better to target the application under development and
211+
the kind of tests we are working on.
212+
213+
214+
To target a specific application for end-to-end tests, use:
215+
```
216+
harness-test . -i [APPNAME] -e
217+
```
218+
219+
To target a specific application for api tests, use:
220+
```
221+
harness-test . -i [APPNAME] -a
222+
```
223+
224+
Note that the local version of the openapi.yaml file located at applications/[APPNAME]/api/openapi.yaml is used if available. That's useful to tweak examples and responses
225+
used by schemathesis to generate the test hypotheses.
226+
208227
## Create test users for your application
209228
210229
To create test users:

tools/cloudharness-test/cloudharness_test/api.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ def run_api_tests(root_paths, helm_values: HarnessMainConfig, base_domain, inclu
6363
schema_file = f"applications/{app_config.name}/api/openapi.yaml"
6464

6565
for path in root_paths:
66+
# use local schema if available to simplify test development
6667
if os.path.exists(os.path.join(path, schema_file)):
6768
app_env["APP_SCHEMA_FILE"] = schema_file
6869

tools/cloudharness-test/cloudharness_test/apitest_init.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,11 @@
1111
app_url = os.environ.get("APP_URL", "http://samples.ch.local/api")
1212
logging.info("Start schemathesis tests on %s", app_url)
1313
if app_schema:
14+
# Test locally with harness-test -- use local schema for convenience during test development
1415
openapi_uri = app_schema
1516
schema = st.from_file(openapi_uri)
1617
else:
18+
# remote testing: might be /api/openapi.json or /openapi.json
1719
try:
1820
openapi_uri = openapi_uri = app_url + "/openapi.json"
1921
schema = st.from_uri(openapi_uri)

0 commit comments

Comments
 (0)