擅长:python、mysql、java
<p>您不必手动运行测试。<a href="http://pytest.org/latest/goodpractices.html#choosing-a-test-layout-import-rules" rel="noreferrer">Pytest finds and executes them automatically</a>:</p>
<pre><code># tests/test_positive.py
def test_pos_1():
populate_page()
check_values()
def test_pos_2():
process_entry()
validate_result()
</code></pre>
<p>以及</p>
<pre><code># tests/test_negative.py
def test_neg_1():
populate_page()
validate_error()
</code></pre>
<p>如果你跑了</p>
<pre><code>py.test
</code></pre>
<p>它们应该自动被捡起来。</p>
<p>然后还可以选择单个文件</p>
<pre><code>py.test -k tests/test_negative.py
</code></pre>
<p>或者一次测试</p>
<pre><code>py.test -k test_neg_1
</code></pre>