-
-
Notifications
You must be signed in to change notification settings - Fork 156
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG] Stateful testing restarts too soon and API is not explored #1627
Comments
Hello, I Just wanted to add that for now we solved this by using the CLI tool with python hooks, and the API exploration goes far more better in respect to the state machine version. |
Thank you for opening this and sorry for the delay! It is indeed true and caused by the internal implementation of Hypothesis state machine. I know where to make change in the Hypothesis codebase, but there is no public API to control it from the outside. Probably it could be just copy-pasted with the change here, but I need to explore it more |
Hi @fscarlato! Schemathesis |
Checklist
Describe the bug
Stateful testing seems a really powerful for automating the API exploration, but it's difficult to make it work. It just stops too soon and filters lot of data.
I'll attacch a simple case where i get a subset of the schema, configured with links, and run it.
I run the test with
pytest -s --log-cli-level=INFO --junitxml=report.xml -v test.py
so the output is shown as the tests goes, as you can see the machine is restarted a lot of times, and the actual examples wich are tried are just a few between each run.Test Output
INFO root:state-machine-ad-hoc-service.py:55 RESTARTINFO root:state-machine-ad-hoc-service.py:55 RESTART
INFO root:state-machine-ad-hoc-service.py:55 RESTART
INFO root:state-machine-ad-hoc-service.py:63 PUT /api-portale/api/v1/organizations/{organization_id}
INFO root:state-machine-ad-hoc-service.py:55 RESTART
INFO root:state-machine-ad-hoc-service.py:55 RESTART
INFO root:state-machine-ad-hoc-service.py:55 RESTART
INFO root:state-machine-ad-hoc-service.py:63 POST /api-portale/api/v1/contacts
INFO root:state-machine-ad-hoc-service.py:63 POST /api-portale/api/v1/contacts
INFO root:state-machine-ad-hoc-service.py:55 RESTART
INFO root:state-machine-ad-hoc-service.py:55 RESTART
INFO root:state-machine-ad-hoc-service.py:55 RESTART
INFO root:state-machine-ad-hoc-service.py:55 RESTART
INFO root:state-machine-ad-hoc-service.py:55 RESTART
INFO root:state-machine-ad-hoc-service.py:63 GET /api-portale/api/v1/contacts/{contact_id}
INFO root:state-machine-ad-hoc-service.py:63 POST /api-portale/api/v1/organizations
INFO root:state-machine-ad-hoc-service.py:63 POST /api-portale/api/v1/contacts
INFO root:state-machine-ad-hoc-service.py:63 PUT /api-portale/api/v1/organizations/{organization_id}
INFO root:state-machine-ad-hoc-service.py:63 POST /api-portale/api/v1/organizations
INFO root:state-machine-ad-hoc-service.py:55 RESTART
To Reproduce
I've attacched the openapi yaml, this is the test code, note that rising up the max_examples and stateful_step_count doesn't improve the behaviour.
Expected behavior
The full machine gets explored by schemathesis. This is a simple case, but rarely it can follow the link createOrganization -> updateOrganization because with these few tries it cannot build randomly a valid Organization.
Furthermore, when I raise the
max_examples
or thestateful_step_count
, the tests stops with:hypothesis.errors.FailedHealthCheck: It looks like your strategy is filtering out a lot of data.
Nothing really changes if I suprress this healthCheck, the state machine still stops too soon.
openapi.yaml.txt
The text was updated successfully, but these errors were encountered: