allure reporting framework pytest

First, what is pytest

pytest is a testing framework python, with unittest functionality and richer than it is.

Second, what is the allure

There are a lot of good testing framework, but there is very little good reporting tool can show very clearly the use case implementation process and results.

allure is an open source tool designed to show the test results in the hope that within the team everyone can see a very clear test results.

allure can be done with a lot of well-known test framework integration.

     Java like language, can be integrated with junit4, junit5, TestNG testing framework.

     python language, can be integrated with pytest, behave, nose test framework.

Save allure will be the test case execution data to xml file them, and then use the command line allure files into html form presented.

 

Third, the installation allure

  allure is integrated together with pytest used, so it is necessary to install pytest and allure-pytest plugin:

pip install pytest
pip install allure-pytest

  Next, install the allure, it depends java environment, you need to install and configure in advance jdk jdk environment variable environment variable if not configured, you can jump to this address: https://www.cnblogs.com/TerLeeHost/p/7890428 .html

installation steps:

Official website provides each platform, command-line installation.

The following is a manual installation for each platform:

1, download the latest installation package from Maven Center:

https://dl.bintray.com/qameta/maven/io/qameta/allure/allure-commandline/

  • Select the latest version of the installation package -----> Download the zip format installation package

2, the unpack to any directory. It recommended not to vote for the C drive or path deep. For example, D: \ allure-command-2.12.1

3, after the jump to extract the bin directory, execute allure.bat under windows. Other platforms perform allure.

4, configure the allure of environment variables:

System variables added: ALLURE_HOME: D: \ allure-2.12.1

System variables: Path added:% ALLURE_HOME% \ bin

  

5, which run from the command line allure --version, or allure

 

 

 Four, Allure and pytest integration

  Test report file generated allure

  In the implementation of pytest command, add allure command parameters: -alluredir = Outputs / allure (relative to the directory where the test reports pytest command directory)

if __name__ == '__main__':
    pytest.main(["-s","-v","--html=Outputs/reports/pytest.html",
                 "--alluredir=Outputs/allure"])   # allure文件生成的目录

or

IF  the __name__ == ' __main__ ' :
     # generate a report file allure 
    pytest.main ([ ' -s ' , ' -v ' , ' --alluredir = OUTPUTS / allure ' ])

  All use cases executed, in OutPuts / allure directory will generate a number of reports document

Third, generate test reports allure html page

1, generate reports allure

  In the cmd command line or console them, execute: Allure serve test result files in the directory , it will generate nice html report.

  比如:allure serve Outputs/allure

 

 

Share Gangster: pytest series (four) - pytest + allure + jenkins - continuous integration platform generates allure Report: https://www.cnblogs.com/Simple-Small/p/11512337.html

******* Please respect the original, as to reprint, please indicate the source: Reprinted from: https://www.cnblogs.com/shouhu/ , thank you! ! ******* 

Guess you like

Origin www.cnblogs.com/shouhu/p/12420064.html