Skip to content

Commit

Permalink
docs: Update documentation for the --max-response-time option
Browse files Browse the repository at this point in the history
  • Loading branch information
Stranger6667 committed Oct 2, 2020
1 parent 286ac27 commit 7847d28
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 2 deletions.
36 changes: 36 additions & 0 deletions docs/cli.rst
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,42 @@ To make Schemathesis perform all built-in checks use ``--check all`` CLI option:
======================= 3 passed in 1.69s =======================
Additionally, you can define the response time limit with ``--max-response-time``.
If any response will take longer than the provided value (in milliseconds) than it will indicate a failure:

.. code:: text
$ schemathesis run --max-response-time=50 ...
================ Schemathesis test session starts ===============
platform Linux -- Python 3.8.5, schemathesis-2.5.0, ...
rootdir: /
hypothesis profile 'default' -> ...
Schema location: http://api.com/swagger.json
Base URL: http://api.com/
Specification version: Swagger 2.0
Workers: 1
collected endpoints: 1
GET /api/slow F [100%]
============================ FAILURES ===========================
_________________________ GET: /api/slow ________________________
1. Response time exceeded the limit of 50 ms
Run this Python code to reproduce this failure:
requests.get('http://127.0.0.1:8081/api/slow')
Or add this option to your command line parameters:
--hypothesis-seed=103697217851787640556597810346466192664
============================ SUMMARY ============================
Performed checks:
not_a_server_error 2 / 2 passed PASSED
max_response_time 0 / 2 passed FAILED
======================= 1 failed in 0.29s =======================
API authorization
-----------------

Expand Down
2 changes: 1 addition & 1 deletion src/schemathesis/runner/impl/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ def run_checks( # pylint: disable=too-many-arguments

if max_response_time:
if elapsed_time > max_response_time:
message = "Check 'max_response_time' failed"
message = f"Response time exceeded the limit of {max_response_time} ms"
errors.append(AssertionError(message))
result.add_failure("max_response_time", case, message)
else:
Expand Down
2 changes: 1 addition & 1 deletion test/cli/test_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -1492,4 +1492,4 @@ def test_max_response_time(cli, server, schema_url, workers):
assert lines[10].startswith("F")
# And the proper error message should be displayed
assert "max_response_time 0 / 2 passed FAILED" in result.stdout
assert "Check 'max_response_time' failed" in result.stdout
assert "Response time exceeded the limit of 50 ms" in result.stdout

0 comments on commit 7847d28

Please sign in to comment.