擅长:python、mysql、java
<p><strong>pytest</strong>具有选项<code>-x</code>或<code>--exitfirst</code>,该选项在第一个错误或失败的测试时立即停止执行测试。</p>
<p><strong>pytest</strong>还有一个选项<code>--max-fail=num</code>,其中<code>num</code>表示停止执行测试所需的错误或失败数。</p>
<pre><code>pytest -x # if 1 error or a test fails, test execution stops
pytest --exitfirst # equivalent to previous command
pytest --maxfail=2 # if 2 errors or failing tests, test execution stops
</code></pre>