maven 之 cobertura 简单使用

编程技术  /  houtizong 发布于 3年前   261

1. 创建一个maven项目

2. 创建com.CoberturaStart.java

package com;public class CoberturaStart {public void helloEveryone(){System.out.println("============================================================");System.out.println("hello everyone!!!");System.out.println("============================================================");}public void goodMorningGentleman(){System.out.println("============================================================");System.out.println("good morning,gentleman!!!");System.out.println("============================================================");}}

 3. 创建以下测试类

    com.HelloEveryoneTest.java 

package com;import org.junit.Test;import junit.framework.Assert;public class HelloEveryoneTest {@Testpublic void testHelloEveryone(){CoberturaStart coberturaStart = new CoberturaStart();coberturaStart.helloEveryone();Assert.assertTrue(true);}}

    com.GoodMorningGentlemanTest.java

package useless;import junit.framework.Assert;import org.junit.Test;import com.CoberturaStart;public class GoodMorningGentlemanTest {@Testpublic void testGoodMorningGentleman(){CoberturaStart coberturaStart = new CoberturaStart();coberturaStart.goodMorningGentleman();Assert.assertTrue(true);}}

4. pom.xml

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"><modelVersion>4.0.0</modelVersion><groupId>MavenProject</groupId><artifactId>MavenProject</artifactId><version>0.0.1-SNAPSHOT</version><build><plugins><plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-surefire-plugin</artifactId><configuration><excludes><exclude>useless/CoberturaStartTest.class</exclude></excludes></configuration></plugin></plugins></build><reporting><plugins><plugin><groupId>org.codehaus.mojo</groupId><artifactId>cobertura-maven-plugin</artifactId><version>2.5.1</version></plugin></plugins></reporting><dependencies><dependency><groupId>junit</groupId><artifactId>junit</artifactId><version>4.0</version><scope>test</scope></dependency></dependencies></project>

maven-surefire-plugin 指明了哪些测试类我们将使用或不使用。(上面案例指明useless/CoberturaStartTest将不被使用)

上一篇:Jqplot之折线图
下一篇:通过XSD验证XML

请勿发布不友善或者负能量的内容。与人为善,比聪明更重要!

留言需要登陆哦

技术博客集 - 网站简介:
前后端技术:
后端基于Hyperf2.1框架开发,前端使用Bootstrap可视化布局系统生成

网站主要作用:
1.编程技术分享及讨论交流,内置聊天系统;
2.测试交流框架问题,比如:Hyperf、Laravel、TP、beego;
3.本站数据是基于大数据采集等爬虫技术为基础助力分享知识,如有侵权请发邮件到站长邮箱,站长会尽快处理;
4.站长邮箱:[email protected];

      订阅博客周刊 去订阅

文章归档

文章标签

友情链接

Auther ·HouTiZong
侯体宗的博客
© 2020 zongscan.com
版权所有ICP证 : 粤ICP备20027696号
PHP交流群 也可以扫右边的二维码
侯体宗的博客