简体   繁体   中英

Is it possible to generate Allure report in python-unittest?

I have found solution for allure report in Pytest. But I need to generate allure report in python-unittest. Is it possible?

By adding allure decorators

  • @allure.story('Story/Requirement Name')
  • @allure.feature('Feature Name')
  • @allure.testcase("Test Case name")

for instance

def test_nameOfTheTest(self):
    with allure.step("Open browser"):

or at the definitions you can use

@allure.step("Open application") 
def open_application(self):

for running the tests:

python -m pytest nameOftheFile.py(considering its in the root) --alluredir ./results

Getting the results:

allure serve ./results/

Hope this should help you

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'])

I using this code to my Test_runner.py and it's can export and open report on browser after done code

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM