Python测试-pytest+allure生成测试报告-environment

在上一篇中介绍了怎么安装及其基础的使用,接下来记录一下怎么定制自己的测试报告。
参考:https://blog.csdn.net/qq_42610167/article/details/101204066
这里主要记录一下allure的environment设置,网上很多都是介绍用allure.environment(platform_name=‘Android’)这种方法设置,但是在allure2中不支持。
目前allure2暂不支持allure.environment(host=‘127.0.0.1’)这种方法设置环境注解,不过在生成报告之前,可以通过把environment.properties (or environment.xml) 文件放到生成的allure-results(也就是测试结果集文件夹,有的可能起名为report/)文件夹(也就是:pytest.main(['-s', 'test_api.py', '--alluredir={}'.format(REPORT_DIR)])中的这个REPORT_DIR文件夹)下来添加(参考官方说明:Environment)。
environment.properties

Browser=Chrome
Browser.Version=63.0
Stand=Production

or environment.xml

<environment>
    <parameter>
        <key>Browser</key>
        <value>Chrome</value>
    </parameter>
    <parameter>
        <key>Browser.Version</key>
        <value>63.0</value>
    </parameter>
    <parameter>
        <key>Stand</key>
        <value>Production</value>
    </parameter>
</environment>

我是直接使用如下命令将所用的环境放在了environment.properties里边,这个根据自己的需求来单独设置。

os.system('pip freeze > allure-results/environment.properties')

如图:
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容