Jenkins集成sonar无法读取jacoco junit测试覆盖率信息

1.需求场景

项目基于ant(build.xml)编译,jacoco 配合junit测试均已通过,但sonar无法展示代码覆盖率。

(1)ant 编译项目排除与bean同包下的hbm.xml文件,导致无法运行junit测试

(2)Warn:Coverage infomation was not collected, Perhaps you forget to include debug information into compiled classes?

 

2.项目环境

struts2 spring2.5 hibernate3 代码编译环境使用jdk 1.7 ant Jenkins2.8  sonarqube7.4  使用 jdk1.8  gitlab

3.解决方案

(1)确认Jenkins 能正常构建项目(将hbml文件拷贝到编译后的目录)

<copy todir="${build.classes}/com/demo/bean">
 <fileset dir="src/com/demo/bean/">
   <include name="*.hbm.xml">
 </fileset>
</copy>

(2)确认Jenkins 扫描到的junit测试都成功运行

(3)确认sonar配置,以及jacoco.exec文件正常生成

(3)将ant编译项目的编译级别开启debug模式

<target name="compile" depends="init">
		<javac srcdir="${src.dir}" destdir="${build.classes}" encoding="UTF-8" includeantruntime="on" target="1.7" source="1.7" debug="on">
			<classpath refid="compile.classpath"></classpath>
		</javac>
	</target>

引用

http://www.mamicode.com/info-detail-2313065.html  ant+jacoco+junit 配置

https://blog.csdn.net/mevicky/article/details/72828554 ant配置

https://www.yiibai.com/ant/apache-ant-java-task.html ant javac 配置

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值