Skip to content

Commit

Permalink
#703 improve docs and code clarity
Browse files Browse the repository at this point in the history
  • Loading branch information
filippomc committed Aug 24, 2023
1 parent 86d3c86 commit 042189b
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
21 changes: 20 additions & 1 deletion docs/testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ deployment.
In order to use `harness-test` install the library with

```
pip install -r requirements-test.txt
pip install -e tools/cloudharness-test
```
In order to run tests against an existing deployment based on a domain (say, my.domain), run:
Expand All @@ -205,6 +205,25 @@ If you want to run the deployment locally and then run the tests, can use skaffo
1. Wait the deployment to settle
1. Run `harness-test PATHS`
### Tests development
The `harness-test` client is useful while developing and tweaking the tests.
In that case it's better to target the application under development and
the kind of tests we are working on.
To target a specific application for end-to-end tests, use:
```
harness-test . -i [APPNAME] -e
```
To target a specific application for api tests, use:
```
harness-test . -i [APPNAME] -a
```
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
used by schemathesis to generate the test hypotheses.
## Create test users for your application
To create test users:
Expand Down
1 change: 1 addition & 0 deletions tools/cloudharness-test/cloudharness_test/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ def run_api_tests(root_paths, helm_values: HarnessMainConfig, base_domain, inclu
schema_file = f"applications/{app_config.name}/api/openapi.yaml"

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

Expand Down
2 changes: 2 additions & 0 deletions tools/cloudharness-test/cloudharness_test/apitest_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@
app_url = os.environ.get("APP_URL", "http://samples.ch.local/api")
logging.info("Start schemathesis tests on %s", app_url)
if app_schema:
# Test locally with harness-test -- use local schema for convenience during test development
openapi_uri = app_schema
schema = st.from_file(openapi_uri)
else:
# remote testing: might be /api/openapi.json or /openapi.json
try:
openapi_uri = openapi_uri = app_url + "/openapi.json"
schema = st.from_uri(openapi_uri)
Expand Down

0 comments on commit 042189b

Please sign in to comment.