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
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持自学编程网。
- 本文固定链接: https://zxbcw.cn/post/200485/
- 转载请注明:必须在正文中标注并保留原文链接
- QQ群: PHP高手阵营官方总群(344148542)
- QQ群: Yii2.0开发(304864863)