【发布时间】:2019-12-03 10:01:58
【问题描述】:
我在 Pytest 中找到了魅力报告的解决方案。但我需要在 python-unittest 中生成魅力报告。有可能吗?
【问题讨论】:
标签: python selenium-webdriver python-unittest allure
我在 Pytest 中找到了魅力报告的解决方案。但我需要在 python-unittest 中生成魅力报告。有可能吗?
【问题讨论】:
标签: python selenium-webdriver python-unittest allure
import sys, os, pytest, subprocess
if __name__ == "__main__":
#Run allure report of this file, export report to PJ/Reports
pytest.main(['-s', '-q','--alluredir','path_store_allure_report,'Test.py'])
#Open allue report via browser
subprocess.run([r'powershell.exe', r'allure ' + 'serve ' + 'path_store_allure_report'])
我将此代码用于我的 Test_runner.py,它可以在完成代码后在浏览器上导出和打开报告
【讨论】:
通过添加诱惑装饰器
例如
def test_nameOfTheTest(self):
with allure.step("Open browser"):
或者你可以使用的定义
@allure.step("Open application")
def open_application(self):
用于运行测试:
python -m pytest nameOftheFile.py(considering its in the root) --alluredir ./results
得到结果:
allure serve ./results/
希望对你有帮助
【讨论】: