
- 自动化测试执行完毕后,需要测试报告来层现测试结果。有个‘像样’的报告的好处是毋庸置疑的,今天就来简单的讲述一下自动化测试后经常使用到的测试报告
Allure
本文首发于伊洛的个人博客:https://yiluotalk.com,欢迎关注并查看更多内容!!!
1. 安装
-
Mac
下安装直接homebrew
#伊洛Yiluo
#https://www.yiluotalk.com
brew install allure
- 检查一下安装的结果
#伊洛Yiluo
#https://www.yiluotalk.com
➜ ~ allure --version
2.13.1
- 以上说明已经成功安装
2. 安装allure-pytest
#伊洛Yiluo
#https://www.yiluotalk.com
pip install allure-pytest
3. 举个栗子
# 伊洛Yiluo
# https://www.yiluotalk.com
import pytest
def test_success():
assert True
def test_failure():
assert False
def test_skip():
pytest.skip('跳过测试')
def test_broken():
raise Exception('出错了')
- 生成报告分2个步骤(后面是生成报告的路径)
# 伊洛Yiluo
# https://www.yiluotalk.com
pytest --alluredir=/tmp/my_allure_results
# 伊洛Yiluo
# https://www.yiluotalk.com
allure serve /tmp/my_allure_results
- 实际尝试下查看结果
# 伊洛Yiluo
# https://www.yiluotalk.com
E assert False
test_sample.py:13: AssertionError
___________________________________ test_broken ___________________________________
def test_broken():
> raise Exception('出错了')
E Exception: 出错了
test_sample.py:21: Exception
===================== 2 failed, 1 passed, 1 skipped in 0.08s ======================
# 伊洛Yiluo
# https://www.yiluotalk.com
Generating report to temp directory...
Report successfully generated to /var/folders/76/fkp3njt56f97wsxgpy94mjh00000gn/T/1826909724101378741/allure-report
Starting web server...
2019-12-24 14:34:54.474:INFO::main: Logging initialized @13022ms to org.eclipse.jetty.util.log.StdErrLog
Server started at <>. Press <Ctrl+C> to exit
4. 查看测试报告
-
执行完上面的命令后会自动打开默认的浏览器显示测试报告



欢迎下方【戳一下】【点赞】
Author:伊洛Yiluo
愿你享受每一天,Just Enjoy !

网友评论