pytest的testdox格式报告程序
pytest-testdox的Python项目详细描述
pytest的TestDox format报告者
安装
pip install pytest-testdox
用法
运行pytest时添加参数testdox。示例:
pytest --testdox your-tests/
提示:如果不想每次运行pytest时都键入--testdox,请添加它 到addopts 在你的ini file里。示例:
# content of pytest.ini# (or tox.ini or setup.cfg)[pytest]addopts=--testdox
标记
@pytest.mark.describe
重写testdox报告中的类名。示例
# test_demo.py@pytest.mark.describe('create_file')classTestCreateFile():deftest_creates_a_file_in_the_so(self):pass
将产生输出:
test_demo.py create_file [x] creates a file in the so
@pytest.mark.it
重写testdox报告中的测试标题。示例:
# test_demo.pyclassTestCreateFile():@pytest.mark.it('Creates a local file in the SO')deftest_creates_a_file_in_the_so(self):pass
将产生输出:
test_demo.py Create File [x] Creates a local file in the SO
配置文件选项
testdox_格式
指定testdox报告格式,plaintext或utf8(默认: utf8)。示例:
# content of pytest.ini# (or tox.ini or setup.cfg)[pytest]testdox_format=plaintext
$ pytest test_demo.py ============================= test session starts ============================== platform darwin -- Python 3.5.0, pytest-3.0.7, py-1.4.33, pluggy-0.4.0 rootdir: /private/tmp/demo, inifile: pytest.ini plugins: testdox-dev collected 2 items test_demo.py Pytest Testdox [x] prints a BDD style output to your tests [x] lets you focus on the behavior