一、安装

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.覆盖率工具使用




 
posted on 2020-04-09 14:16  温暖的阳光  阅读(2715)  评论(0编辑  收藏  举报