首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

开源测试报告工具Allure安装

Allure Test Report 是一款灵活的轻量级多语言测试报告工具。

环境搭建过程

安装JDK(过程百度)

下载Allure

解压zip包,进入allure/bin下,该文件下两个文件allure.bat(windows)和 allure(linux),执行pytest命令用。

使用稳定版,最新版默认没有bin目录,为什么我也不知道~

添加环境变量

将bin目录加到环境变量。运行allure --version查看是否可用。

安装第三方库

pip install allure-pytestallure-pytest 暂时只安装这一个就行,pytest 会被当做依赖安装好。

执行脚本并生产报告数据

任意创建一个项目,在项目下命令行执行 pytest --alluredir report

执行pytest 生产allure测试结果数据,存放到report下。

此时在项目下会多一个report 文件夹。

生产测试报告

项目根目录下执行 allure generate --clean report -o html。执行成功返回:Report successfully generated to html

执行allure生成报告,数据目录是 report ,报告生成 在html 目录

打开报告

项目根目录下执行allure open html。浏览器会默认打开报告。

代码语言:javascript
复制
Starting web server...
2020-03-18 23:35:41.157:INFO::main: Logging initialized @209ms to org.eclipse.jetty.util.log.StdErrLog
Server started at <http://10.0.63.105:53297/>. Press <Ctrl+C> to exit

allure 命令

代码语言:javascript
复制
Usage: allure [options] [command] [command options]
  Options:
    --help
      Print commandline help.
    -q, --quiet
      Switch on the quiet mode.
      Default: false
    -v, --verbose
      Switch on the verbose mode.
      Default: false
    --version
      Print commandline version.
      Default: false
  Commands:
    generate      生成报告
      Usage: generate [options] The directories with allure results
        Options:
          -c, --clean
            Clean Allure report directory before generating a new one.
            Default: false
          --config
            Allure commandline config path. If specified overrides values from
            --profile and --configDirectory.
          --configDirectory
            Allure commandline configurations directory. By default uses
            ALLURE_HOME directory.
          --profile
            Allure commandline configuration profile.
          -o, --report-dir, --output
            The directory to generate Allure report into.
            Default: allure-report

    serve      Serve the report
      Usage: serve [options] The directories with allure results
        Options:
          --config
            Allure commandline config path. If specified overrides values from
            --profile and --configDirectory.
          --configDirectory
            Allure commandline configurations directory. By default uses
            ALLURE_HOME directory.
          -h, --host
            This host will be used to start web server for the report.
          -p, --port
            This port will be used to start web server for the report.
            Default: 0
          --profile
            Allure commandline configuration profile.

    open      Open generated report
      Usage: open [options] The report directory
        Options:
          -h, --host
            This host will be used to start web server for the report.
          -p, --port
            This port will be used to start web server for the report.
            Default: 0

    plugin      Generate the report
      Usage: plugin [options]
        Options:
          --config
            Allure commandline config path. If specified overrides values from
            --profile and --configDirectory.
          --configDirectory
            Allure commandline configurations directory. By default uses
            ALLURE_HOME directory.
          --profile
            Allure commandline configuration pr

安装过程很简单。下载解压,添加环境变量。linux和window没什么区别。

之后分享报告使用过程中的心得和技巧~

下一篇
举报
领券