首页 > 解决方案 > 是否可以在 python-unittest 中生成 Allure 报告?

问题描述

我在 Pytest 中找到了魅力报告的解决方案。但我需要在 python-unittest 中生成魅力报告。可能吗?

标签: pythonselenium-webdriverpython-unittestallure

解决方案


通过添加魅力装饰器

  • @allure.story('故事/需求名称')
  • @allure.feature('功能名称')
  • @allure.testcase("测试用例名称")

例如

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/

希望这可以帮助你


推荐阅读