次のコード(conftest.py)を使用してみましょう:
import random
def test_val():
value = random.random()
assert value < 0.5
実行中のpy.test --junitxml=result.xml conftest.py
生成result.xml
(テストに合格した場合):
<?xml version="1.0" encoding="utf-8"?>
<testsuite errors="0" failures="0" name="" skips="0" tests="1" time="0.047">
<testcase classname="conftest" name="test_val" time="0.0"/>
</testsuite>
今。私ができるようにしたいのは、で生成された値をに格納することtest_val()
ですresults.xml
。それを行う方法はありますか?pytestdocに関連するものが見つからないようです。