Generate an allure report using pytest

I am using py test allure adapter and trying to generate the input needed for an allure report. But I can not generate any XML. When I execute the py file using py.test sample.py, it created the pycache directory. Then I did "allure generate -v 1.3.9 C: \ allurereports" (this is the directory where I had sample.py). He did create an html allure report, but there were no test cases. There were no details.

Sample sample.py (it is similar to the example)

import allure @allure.feature('Feature1') @allure.story('Story1') def test_minor(): assert False @allure.feature('Feature2') @allure.story('Story2', 'Story3') @allure.story('Story4') class TestBar: # will have 'Feature2 and Story2 and Story3 and Story4' def test_bar(self): pass 

The py.test command is used here: py.test sample.py --allure_features = feature1, feature2

Can someone help me create a temptation report from a file. What are the commands to execute.

+5
source share
5 answers

Lavanya. I will try to explain the sequence that you must follow in order to generate an aurootest report.

  • Install pip . Download get-pip.py and execute python get-pip.py .

  • Install pytest and pytest-allure-adapter via pip. Run python -m pip install pytest pytest-allure-adapter

  • Report on the autotest allure xml object. Run python -m pytest sample.py --alluredir <some directory>

  • In <some directory> An xml autotest report appears containing the results of the sample.py tests. Let us report on the beauty of html through the allure-cli tool.

  • Install allure-cli. Download the latest version of allure-cli . allure-cli requires java. allure-cli does not require installation, just unzip and use it .

  • Create html report. Find allure (allure.bat for Windows) in the unpacked mailbox. Run allure.bat generate -o <some directory> -v 1.4.0 <some directory>

  • Find index.html in <some directory> and open it through a browser.

* Note <some directory> is the same for all steps

+15
source

You must specify a directory with your test data (a directory containing the -testsuite.xml files), not a test directory .

You can use py.test --alluredir [path_to_report_dir] to request it.

PS. Make sure you are using the correct version of allure (the latest pytest adapter only supports allure 1.4. *).

For more information see https://github.com/allure-framework/allure-python and https://github.com/allure-framework/allure-cli

+1
source

you should now use allure-command-line instead of allure-cli to generate an html report because the second is deprecated.

0
source

There is a very easy way to generate reports through Allure.

Install Allure first. (1) allure-pytest 2.6.0 (2) allure-python-commons 2.6.0

then, if you were unable to generate reports, follow these steps. step -1 (using pytest) pytest test_xyz.py --alluredir = the path where you want to save reports.

step -2 allure serve report_path

if it still shows that the charm is not recognized, the command (blah -blah)

then install allure using the npm plugin using the command below

npm install -g allure-commandline --save-dev

then follow step -2 again, then one server will start and you will be able to see charm reports.

0
source

This is what I found to work -

 python3 -m pytest [your_test_class_name] --alluredir \Report 

Then follow the next line where you saved your report -

 python3 -m allure serve \Report 

This will open the default charm report in your browser.

Lift your finger up if you find that it works.

0
source

Source: https://habr.com/ru/post/1204957/


All Articles