是否可以在 python-unittest 中生成 Allure 报告?

Rah*_*loy 6 python selenium-webdriver python-unittest allure

我在 Pytest 中找到了魅力报告的解决方案。但我需要在 python-unittest 中生成诱惑报告。是否可以?

小智 -1

通过添加 allure 装饰器

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

例如

def test_nameOfTheTest(self):
    with allure.step("Open browser"):
Run Code Online (Sandbox Code Playgroud)

或者您可以使用的定义

@allure.step("Open application") 
def open_application(self):
Run Code Online (Sandbox Code Playgroud)

运行测试:

python -m pytest nameOftheFile.py(considering its in the root) --alluredir ./results
Run Code Online (Sandbox Code Playgroud)

得到结果:

allure serve ./results/
Run Code Online (Sandbox Code Playgroud)

希望这对您有帮助