allure环境搭建

allure环境搭建
在搭建之前你应该有python、pycharm

allure介绍
官网:https://docs.qameta.io/allure/

英文介绍

Allure Framework is a flexible lightweight multi-language test report tool that not only shows a very concise representation of what have been tested in a neat web report form, but allows everyone participating in the development process to extract maximum of useful information from everyday execution of tests

翻译:

allure是一个框架

灵活、轻量、多语言

测试报告

JDK
allure依赖于JAVA,所以你应该有JAVA环境,如果已经配置过可跳过

推荐用JDK 1.8这样的版本

下载链接:http://www.codebaoku.com/jdk/jdk-oracle-jdk1-8.html

注意自己的操作系统

JAVA_HOME和PATH变量的配置(仅供参考)

pip安装

 pip  install -i https://mirrors.aliyun.com/pypi/simple allure-pytest
说明:

你要用allure,你就要有pytest这个库

安装allure-pytest的时候如果没有pytest是会自动安装的,因为他依赖pytest

 pip show allure-pytest
 
 Name: allure-pytest
 Version: 2.9.45
 Summary: Allure pytest integration
 Home-page: https://github.com/allure-framework/allure-python
 Author: QAMetaSoftware, Stanislav Seliverstov
 Author-email: [email protected]
 License: Apache-2.0
 Location: c:\python39\lib\site-packages
 Requires: allure-python-commons, pytest, six
 Required-by:
你可以理解为allure-pytest是pytest的一个插件

但跟大多数插件不一样的命名allure-pytest,而普通的插件多是pytest-xxx的形式。

注意事项

如果你是新手,你有多个环境(可能是多个python、或有虚拟环境),那推荐在pycharm中安装,那就简单很多,当然也最好配置要安装仓库。

如果你没有配置pip的源,可以手工加-i参数来指定

 pip install -i https://pypi.tuna.tsinghua.edu.cn/simple  allure-pytest
 
 # 类似的源头很多,比如阿里云的
 https://mirrors.aliyun.com/pypi/simple


allure应用程序配置
第一步:下载allure应用程序

你下面2个地址任选其一下载即可。

 https://repo.maven.apache.org/maven2/io/qameta/allure/allure-commandline/ https://github.com/allure-framework/allure2/releases
github地址

maven仓库地址

选择自己的平台版本(windows你可以下载zip格式,linux就tgz),下载,然后解压到某个目录下(下图是2022年的一个截图,你看的到未必一样

第二步:将allure所在的目录配置到PATH中去

此处以allure-2.14.0为图例,所有版本都一样的配置方法

新开一个cmd,输入命令以验证

 C:\Users\songqin008>allure --version
 2.14.0


第三步:重启pycharm,确保能读取到更新后的PATH

首次配置需要

其实也可以手工配置PATH

第四步:编写一个测试代码

DEMO

 
 import pytest,os
 
 def test_001():
     assert 1==1
 
 
 if __name__ == '__main__':
     pytest.main(['-sv',__file__,'--alluredir','./tmp','--clean-alluredir'])
     os.system(f'allure serve ./tmp')
控制台输出

 D:\Python39\python.exe D:/demos/demo_allure.py
 ====================== test session starts======================
 platform win32 -- Python 3.9.6, pytest-7.1.2, pluggy-1.0.0 -- D:\Python39\python.exe
 cachedir: .pytest_cache
 metadata: {'Python': '3.9.6', 'Platform': 'Windows-10-10.0.19044-SP0', 'Packages': {'pytest': '7.1.2', 'py': '1.11.0', 'pluggy': '1.0.0'}, 'Plugins': {'allure-pytest': '2.9.45', 'anyio': '3.5.0', 'Faker': '13.3.4', 'assume': '2.4.3', 'base-url': '1.4.2', 'dependency': '0.5.1', 'forked': '1.4.0', 'html': '3.1.1', 'instafail': '0.4.2', 'metadata': '1.11.0', 'ordering': '0.6', 'repeat': '0.9.1', 'rerunfailures': '10.2', 'sugar': '0.9.4', 'timeout': '2.1.0', 'xdist': '2.5.0'}, 'JAVA_HOME': 'D:\\Java\\jdk1.8.0_301\\', 'Base URL': ''}
 rootdir: D:\pythonProject\AutoTest\AutoHuayan61\demos
 plugins: allure-pytest-2.9.45, anyio-3.5.0, Faker-13.3.4, assume-2.4.3, base-url-1.4.2, dependency-0.5.1, forked-1.4.0, html-3.1.1, instafail-0.4.2, metadata-1.11.0, ordering-0.6, repeat-0.9.1, rerunfailures-10.2, sugar-0.9.4, timeout-2.1.0, xdist-2.5.0
 collecting ... collected 1 item
 
 demo_allure.py::test_001 PASSED
 
 ============================== 1 passed in 0.10s ==============================
 Generating report to temp directory...
 Report successfully generated to C:\Users\SONGQI~1\AppData\Local\Temp\4761329703454998013\allure-report
 Starting web server...
 2022-08-09 11:42:32.445:INFO::main: Logging initialized @2843ms to org.eclipse.jetty.util.log.StdErrLog
 Server started at . Press to exit
会自动打开一个浏览器,界面大致如下,基本就ok了。下面就是学习allure的细节了,此处不表。

最后: 为了回馈铁杆粉丝们,我给大家整理了完整的软件测试视频学习教程,朋友们如果需要可以自行免费领取 【保证100%免费】

 全套资料获取方式:点击下方小卡片自行领取即可

 

你可能感兴趣的:(软件测试,程序员,接口测试,自动化测试,性能测试,测试工程师)