• jenkins展示report测试报告的配置


     

    HTML报告展示

    1. 需要HTML Publisher plugin插件
    2. 在workspace下的工程(构建)中的目录中存储测试报告

    在Jenkins中新建一个job,进入配置项。

    首先通过pytest生成测试报告

     
    pytest执行测试

    注,py.test执行测试后生成报告,会生成在workspace的当前project目录中,例如C:Program Files (x86)Jenkinsworkspacetest_html_report eports eport.html

    配置报告展示

    1) 选择构建后操作步骤 > Publish HTML reports

     
    选择 Publish HTML reports

    2) 配置路径,注意路径是相对于workspace的项目开始,例如当前项目名字为test_html_report,生成的报告存放的位置为

    C:Program Files (x86)Jenkinsworkspace est_html_report eports eport.html。那么配置如下:

     
    HTML报告配置

    3)配置好后,执行构建。构建完成后,就可以在项目页面看到配置的HTML报告

     
    项目页面

    点击进去就可以看到报告的内容:

     
    HTML测试报告

    XML报告展示

    XML报告是Jenkins自带的Junit测试报告展示,不用下载任何插件

    同样以上面的py test例子,开始配置

    1) 同样增加构建后的步骤 > Publish Junit test result report

     
    选择Publish Junit test result report
    1. 同样注意路径
     
    XML报告配置

    3)配置完成后,可以在构建页面看到测试报告了。注意,是构建页面,不是项目页面。HTML报告是展示在项目页面,而xml报告展示在构建页面。

     
    项目页面
     
    构建页面

    就可以看到测试报告了。


     
    XML报告

    附上:test_add.py中随手写的示例测试代码(注意,需要pip intsall pytest)

    def add(a, b):
      return a + b
    
    def test_str():
      '''
      测试字符串
      :return:
      '''
      # 测试失败
      assert add('1', '2') == '112'
    
    def test_int():
      '''
      测试整型
      :return:
      '''
      assert add(1, 2) == 3
    
    
    class TestAdd():
      def test_list(self):
        assert add([1], [2]) == [1,2]
    
      def test_tuple(self):
        assert add((1,), (2,)) == (1,2)
    
     



  • 相关阅读:
    LOJ #6183 看无可看
    BZOJ 5467 Slay the Spire
    BZOJ 5306 [HAOI2018] 染色
    BZOJ 2784 时间流逝
    BZOJ4911: [Sdoi2017]切树游戏
    min-max 容斥
    BZOJ 5475: [WC 2019] 数树
    BZOJ 2810 [Apio2012]kunai
    Codeforces round 1083
    详解大数据数据仓库分层架构
  • 原文地址:https://www.cnblogs.com/VseYoung/p/9976754.html
Copyright © 2020-2023  润新知