一、安裝
1. curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
2. python get-pip.py
3. pip install diff-cover
******
安裝的時候報這個問題:
問題1:
python:ImportError: No module named 'setuptools'
解決方法:yum -y install python-setuptools
執行命令要換成yum才可以哈 https://blog.csdn.net/qq_37212752/article/details/89532388
*********
問題2:pkg_resources.DistributionNotFound: pygments
解決的方法:pip install --upgrade setuptools 連接:https://www.codenong.com/7446187/
或者
首先執行命令:
[root@mini61 setuptools-8.2.1]# python setup.py build
再執行命令:
[root@mini61 setuptools-8.2.1]# python setup.py install
安裝pip的方法
1.yum -y install wget
2.如果沒有epel源下載阿里的epel源
# wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
3.安裝pip
# yum -y install python-pip
二、使用
1.通過mvn和jacoco生成exec文件
junittest.sh 單元測試腳本
#!/bin/bash
cd ${WORKSPACE}/${JOB_BASE_NAME}
sudo ${MAVENHOME}/bin/mvn org.jacoco:jacoco-maven-plugin:prepare-agent -f pom.xml -s ${MAVENHOME}/tmp/settings.xml -gs ${MAVENHOME}/tmp/settings.xml clean test -Dautoconfig.skip=true -Dmaven.test.skip=false -Dmaven.test.failure.ignore=true
在target生成的目錄文件

在surefire-report中的文件目錄,當前測試報告就是以這里面的xml文件做為源文件生成的測試報告

2.
用於測試的源代碼:http://192.168.102.73:8081/CICD/cicd/demo/API-test-demo.git
c48789a85abe7be9fe84adfbcb904bf400fd579d 比較的commitId值,分支:master
3e5a0c253fb3ba97b1a1b3fd3f387174addba709
ant安裝的路徑:/usr/share/ant
執行路徑:/usr/share/ant
exec文件路徑:
將exec轉成xml文件的方法 https://www.cnblogs.com/edwar172038/p/11491267.html
將exec文件轉換稱xml文件的方法:mvn org.jacoco:jacoco-maven-plugin:report -Djacoco.dataFile=/root/API-test-demo/target/jacoco.exec
終於可以用增量覆蓋率工具了,呵呵
3.覆蓋率工具使用