一般企业网站3年多少钱,高端上海网站设计公司,建个个人网站一年多少钱,做防护用品的网站#x1f345; 视频学习#xff1a;文末有免费的配套视频可观看 #x1f345; 关注公众号【互联网杂货铺】#xff0c;回复 1 #xff0c;免费获取软件测试全套资料#xff0c;资料在手#xff0c;涨薪更快 先前博客有介绍pytest测试框架的安装及使用#xff0c;现在来聊… 视频学习文末有免费的配套视频可观看 关注公众号【互联网杂货铺】回复 1 免费获取软件测试全套资料资料在手涨薪更快 先前博客有介绍pytest测试框架的安装及使用现在来聊聊pytest可以生成哪些测试报告
1. allure测试报告
2. 生成resultlog文件
#!/usr/bin/python# -*- coding: UTF-8 -*-author:chenshifengfile:test_report.pytime:2021/01/27class TestReport: def test_one(self): x shifeng assert feng in x def test_two(self): x hello assert x hi
执行命令 pytest test_report.py --resultlog./resultlog.txt
指定当前路径下生成resultlog.txt文件打开文件内容如下
. reportdemo/test_report.py::TestReport::test_oneF reportdemo/test_report.py::TestReport::test_two self test_report.TestReport object at 0x7fd9c0a3eac0 def test_two(self): x hello assert x hi E AssertionError: assert hello hi E - hi E hello test_report.py:16: AssertionError
3. 生成JunitXML文件
执行命令
pytest test_report.py --junitxml./resultlog.xml
同样指定在当前目录下生成resultlog.xml文件打开文件内容如下
?xml version1.0 encodingutf-8?testsuites testsuite errors0 failures1 hostnamechenshifengdeMacBook-Pro.local namepytest skipped0 tests2 time0.072 timestamp2021-01-27T23:56:58.204464 testcase classnamereportdemo.test_report.TestReport filereportdemo/test_report.py line9 nametest_one time0.001/testcase testcase classnamereportdemo.test_report.TestReport filereportdemo/test_report.py line13 nametest_two time0.002 failure messageAssertionError: assert apos;helloapos; apos;hiapos; - hi helloself lt;test_report.TestReport object at 0x7fa152b97790gt; def test_two(self): x quot;helloquot; gt; assert x quot;hiquot; E AssertionError: assert apos;helloapos; apos;hiapos; E - hi E hello test_report.py:16: AssertionError /failure /testcase /testsuite/testsuites
创建这样的XML文件有有什么用 主要是为了方便Jenkin或其它的持续集成工具读取。
4. 生成测试用例的URL
执行命令
pytest test_report.py --pastebinall 复制打印结果最后生成的session-log测试报告链接到浏览器 当然你也可以只选择展示faile的测试用例 pytest test_class.py --pastebinfailed
5. 生成html测试报告
通过pip安装pytest-html pip install pytest-html
在代码文件的当前目录下执行命令
pytest test_report.py --html./report.html 指定在当前目录下生成report.html文件打开测试文件 最后祝大家都能找到心仪的工作快乐工作幸福生活广阔天地大有作为。我也整理了一波之前发布的软件测试文档【点击文末小卡片免费领取】无套路领取 同时在这我为大家准备了一份软件测试视频教程含面试、接口、自动化、性能测试等就在下方需要的可以直接去观看也可以直接【点击文末小卡片免费领取资料文档】
软件测试视频教程观看处 【2024最新版】Python自动化测试15天从入门到精通10个项目实战允许白嫖。。。