<p>以这种方式运行您的命令</p>
<h2>与xunit2</h2>
<p><code>python -m pytest -o junit_family=xunit2 junitxml=test-reports/junit.xml</code></p>
<h2>与xunit1</h2>
<p><code>python -m pytest -o junit_family=xunit1 junitxml=test-reports/junit.xml</code>或</p>
<p><code>python -m pytest -o junit_family=legacy junitxml=test-reports/junit.xml</code></p>
<p><a href="https://docs.pytest.org/en/latest/deprecations.html#junit-family-default-value-change-to-xunit2" rel="noreferrer">This here</a>详细描述了更改:</p>
<blockquote>
<p>The default value of junit_family option will change to xunit2 in
pytest 6.0, given that this is the version supported by default in
modern tools that manipulate this type of file.</p>
<p>In order to smooth the transition, pytest will issue a warning in case
the junitxml option is given in the command line but junit_family is
not explicitly configured in pytest.ini:</p>
<pre><code>PytestDeprecationWarning: The `junit_family` default value will change to 'xunit2' in pytest 6.0. Add `junit_family=legacy` to your
</code></pre>
<p>pytest.ini file to silence this warning and make your suite
compatible.</p>
<p>In order to silence this warning, users just need to configure the
junit_family option explicitly:</p>
<pre><code>[pytest]
junit_family=legacy
</code></pre>
</blockquote>