I have the requirement to stop test cases with overall timeout, not at test case level. so if lets say i have 300 test cases I want to timeout with overall time as 300 seconds.
Is there a way to do that? Sample command used to run pytest pytest.py --junitxml=artifacts/junitresults.xml -s --gatherlogs=true --durations=2000 tests/spark
For each test item the pytest-timeout plugin starts a timer thread which will terminate the whole process after the specified timeout. When a test item finishes this timer thread is cancelled and the test run continues.
Using the norecursedirs option in pytest. ini or tox. ini can save a lot of collection time, depending on what other files you have in your working directory. My collection time is roughly halved for a suite of 300 tests when I have that in place (0.34s vs 0.64s).
The simplest way to skip a test is to mark it with the skip decorator which may be passed an optional reason . It is also possible to skip imperatively during test execution or setup by calling the pytest. skip(reason) function. This is useful when it is not possible to evaluate the skip condition during import time.
take a look at this pytest plugin: https://pypi.python.org/pypi/pytest-timeout it most probably suits your use case.
You can set a global timeout in a number of ways, the most simple one being the --timeout
command line option that "sets a global timeout overriding both the environment variable and configuration option" after which the tests will be terminated:
py.test --timeout=300
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With