5

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

2 Answers2

0

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

suryateja
  • 7
  • 1
0
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

Dharman
  • 30,962
  • 25
  • 85
  • 135
Tips
  • 1