Reputation: 8927
I am using pytest. I like the way I call pytest (re-try the failed tests first, verbose, grab and show serial output, stop at first failure):
pytest --failed-first -v -s -x
However there is one more thing I want:
I want pytest to run the new tests (ie tests never tested before) immediately after the --failed-first ones. This way, when working with tests that are long to perform, I would get most relevant information as soon as possible.
Any way to do that?
Upvotes: 2
Views: 679
Reputation: 4354
For anyone coming to this now, pytest added a --new-first
option to run new tests before all other tests. It can be combined with --failed-first
to run new and failed tests. For test-driven development, I've found it helpful to use these options with pytest-watch, which I described in my blog.
Upvotes: 2
Reputation: 474171
This may not be directly what you are asking about, but, my understanding is that the test execution order is important for you when you create new tests during development.
Since you are already working with these "new" tests, the pytest-ordering
plugin might be a good option to consider. It allows you to influence the execution order by decorating your tests with @pytest.mark.first
, @pytest.mark.second
etc decorators.
pytest-ordering
is able to change the execution order by using a pytest_collection_modifyitems
hook. There is also pytest-random-order
plugin which also uses the same hook to control/change the order.
You can also have your own hook defined and adjusted to your specific needs. For example, here another hook is used to shuffle the tests:
Upvotes: 3