亲宝软件园·资讯

展开

pipeline代码覆盖率 怎样使用pipeline和jacoco获取自动化测试代码覆盖率

乔叶叶 人气:0

1下载jacoco,并上传至服务器:https://www.eclemma.org/jacoco/

2.应用服务tomcat的catalina.sh增加jacocoagent

#JAVA_OPTS="$JAVA_OPTS -javaagent:/Users/qiaojiafei/Documents/work/jacoco/jacoco-0.8.3/lib/jacocoagent.jar=includes=*,classdumpdir=classes,output=tcpserver,address=127.0.0.1,port=6300"

2.jenkins的pipeline配置

node { 
  
  
  stage('Test') { 
    echo 'This is a test step' 
        checkout poll: false, scm: [$class: 'GitSCM', branches: [[name: '*/develop']], doGenerateSubmoduleConfigurations: false, extensions: [], submoduleCfg: [], userRemoteConfigs: [[credentialsId: 'bad9f924--4416-9f5e-', url: 'http://:8000/qiaojiafei/platform-qa.git']]]
        sh 'mvn clean test -DapiTest.xml -Dmaven.test.failure.ignore=true'
  }
  stage('rd code') { 
    echo 'This is a test step' 
        checkout poll: false, scm: [$class: 'GitSCM', branches: [[name: '*/master']], doGenerateSubmoduleConfigurations: false, extensions: [], submoduleCfg: [], userRemoteConfigs: [[credentialsId: 'bad9f924--4416-9f5e-', url: 'http://:8000/qingzhuhotel/qingzhutool.git']]]
        sh 'mvn compile'
  }
  
  stage('DumpFromServer'){
     echo 'This is a DumpFromServer step'  
        sh label: '', script: 'mvn org.jacoco:jacoco-maven-plugin:0.8.3:dump -Djacoco.address=192.168.162.224 -Djacoco.port=6300'
      
    }

  stage('jacoco'){
    jacoco()
  }

}

结果展示

jacoco原理

官网介绍:

https://www.jacoco.org/jacoco/trunk/doc/implementation.html

参考:

https://testerhome.com/topics/5757

加载全部内容

相关教程
猜你喜欢
用户评论