首页 > 其他分享 >Jenkins集成clover做覆盖率报告

Jenkins集成clover做覆盖率报告

时间:2022-10-28 09:15:27浏览次数:50  
标签:集成 clover methodCoverage conditionalCoverage 50 Jenkins 80 true

1.Jenkins安装插件Clover Plugin

2.修改配置文件

<1>.修改pom.xml

dependency部分

<dependency>
    <groupId>junit</groupId>
    <artifactId>junit</artifactId>
    <version>4.13.1</version>
    <scope>test</scope>
    <optional>true</optional>
</dependency>
plugin部分

<plugin> <groupId>com.atlassian.maven.plugins</groupId> <artifactId>clover-maven-plugin</artifactId> <!-- maven-clover2-plugin before 4.1.1 --> <version>4.1.1</version> </plugin>

 

<2>.修改Jenkinsfile

//单元测试阶段
        stage("unit-test") {
            when {
                expression { ENV =~ 'CI.*' }
            }
            steps {
                echo "自动化测试,单元测试"
                sh 'mvn clean clover:setup test clover:aggregate clover:clover'
            }
                //3.收集html测试报告                   
            post {  
                always {
                    script { 
                        //allowEmptyResults: true允许空结果即没有测试报告输出,skipPublishingChecks: true跳过github发布检查
                        if (env.moudle_name == '.') {
                            junit allowEmptyResults: true, skipPublishingChecks: true, testResults: "**/target/surefire-reports/*.xml"
                            clover(cloverReportDir: 'target/site', cloverReportFileName: 'clover.xml',
                            // optional, default is: method=70, conditional=80, statement=80
                            healthyTarget: [methodCoverage: 70, conditionalCoverage: 80, statementCoverage: 80],
                            // optional, default is none
                            unhealthyTarget: [methodCoverage: 50, conditionalCoverage: 50, statementCoverage: 50],
                            // optional, default is none
                            failingTarget: [methodCoverage: 0, conditionalCoverage: 0, statementCoverage: 0]
                        )       

                            publishHTML([allowMissing: false, alwaysLinkToLastBuild: false, keepAll: false, reportDir: 'target/site/clover', reportFiles: 'index.html', reportName: 'HTML Report', reportTitles: ''])
                         }
                        else {
                            junit allowEmptyResults: true, skipPublishingChecks: true, testResults: "**/${params.moudle_name}/target/surefire-reports/*.xml"
                            clover(cloverReportDir: '${params.moudle_name}/target', cloverReportFileName: 'clover.xml',
                            // optional, default is: method=70, conditional=80, statement=80
                            healthyTarget: [methodCoverage: 70, conditionalCoverage: 80, statementCoverage: 80],
                            // optional, default is none
                            unhealthyTarget: [methodCoverage: 50, conditionalCoverage: 50, statementCoverage: 50],
                            // optional, default is none
                            failingTarget: [methodCoverage: 0, conditionalCoverage: 0, statementCoverage: 0]
                        )
                            publishHTML([allowMissing: false, alwaysLinkToLastBuild: false, keepAll: false, reportDir: '${params.moudle_name}/target/site/clover', reportFiles: 'index.html', reportName: 'HTML Report', reportTitles: ''])
                        }
                    
                    }
                }
            }
        }

 

标签:集成,clover,methodCoverage,conditionalCoverage,50,Jenkins,80,true
From: https://www.cnblogs.com/xiaoxiaomuyuyu/p/16834677.html

相关文章

  • 10JMETER之jenkins+jmeter+ant+svn
    1. 数据准备1.1 脚本准备   对应脚本放入SVN固定目录1.2 ant配置:(1)将JMeter所在目录下extras子目录里的ant-JMeter-1.1.1.jar复制到Ant所在目录lib子目录之下(这......
  • 三. jenkins+newman+postman持续集成环境搭建
    Newman简介    Newman是一款基于Node.js开发的,可以运用postman工具直接从命令运行和测试postman集合Newman应用环境准备:js/cnpm或npm配置好环境,执行如下命令......
  • SpringBoot集成Swagger2
    1.新建一个SpringBoot=web项目2.导入相关依赖`io.springfoxspringfox-swagger23.0.0io.springfoxspringfox-swagger-ui3.0.0`3.编写一个Hello工程4.配置Swa......
  • 万物皆可集成系列:低代码对接阿里物流API实现快递跟踪
    随着各大电商网购平台的发展,快递业已形成一个规模庞大的产业,据统计,全球快递企业已超过千家,而快递查询对于电商平台而言是最基础的功能之一,通过输入快递单号,不用区分具体是哪......
  • 080_SpringBoot集成ES
    目录官方文档ElasticsearchclientsJavaRESTClientJavaHighLevelRESTClientGettingstartedMavenconfiguration初始化Initialization搭建测试环境创建空项目创建模......
  • 二. jmeter+ant+jenkins接口自动化测试平台
    平台搭建  (1).录制jmeter脚本  (2).将jmeter的安装目录下的G:\jmeter\apache-jmeter-5.1.1\extras中,将”ant-jmeter-1.1.1.jar”文件放到ant的lib目录下  ......
  • Springboot集成easypoi实现excel多sheet导出
    1.环境配置<!--easypoi依赖,excel导入导出--><dependency><groupId>cn.afterturn</groupId><artifactId>easypoi-spring-boot-starter</artifactId><vers......
  • Jenkins java服务更新和回滚
    [root@jenkinsscripts]#catjava_deploy_tag_rollback.sh#!/bin/bashDATE=$(date+%Y-%m-%d-%H-%M-%S)web_server="192.168.220.143192.168.220.144"Sdir=/optDd......
  • AgileBoot - 如何集成内置数据库H2和内置Redis
    背景介绍为什么我们需要内置的数据库和Redis呢?优点:内置的数据库H2,可以让我们在无依赖数据库的情况下,做集成测试。比如我们想测试添加一个学生到数据库,就需要启动一台数据库......
  • Jenkins pipeline:pipeline 语法详解
    jenkins pipeline总体介绍 pipeline是一套运行于jenkins上的工作流框架,将原本独立运行于单个或者多个节点的任务连接起来,实现单个任务难以完成的复杂流程编排与可......