前言: 对Eclipse的工程写单元测试:

    1. 一个工程有多个测试类,将测试类放到一个测试包下。

    2. 每一个测试类写好,都单独执行run as ->JUnit Test测一下。

      3. Junit 测试报告简单明了。

一、使用maven-surefire-plugin插件自带report功能

注意:

1、单独运行mvn test,默认执行的就是maven-surefire-plugin

2、配置了maven-surefire-plugin后,运行mvn test,结果和1一致,生成xml、txt文件

3、运行mvn test surefire-report:report 即是:运行mvn test的基础上,根据生成的xml、txt文件,再生成默认格式的report

<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.0.2</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<testFailureIgnore>true</testFailureIgnore>
<includes>
<include>**/*Test.java</include>
</includes>
<excludes>
<!-- -->
</excludes>
</configuration>
</plugin>
</plugins>

二、用Maven 运行项目。

mvn surefire-report:report

三、使用maven-antrun-extended-plugin

使用maven-surefire-plugin生成的报告太简陋,可以通过maven-antrun系列插件生成更好的报告。

<!-- 用mvn ant生成格式更友好的report -->
<plugin>
<groupId>org.jvnet.maven-antrun-extended-plugin</groupId>
<artifactId>maven-antrun-extended-plugin</artifactId>
<executions>
<execution>
<id>test-reports</id>
<phase>test</phase>
<configuration>
<tasks>
<junitreport todir="${basedir}/target/surefire-reports">
<fileset dir="${basedir}/target/surefire-reports">
<include name="**/*.xml" />
</fileset>
<report format="frames" todir="${basedir}/target/surefire-reports" />
</junitreport>
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.apache.ant</groupId>
<artifactId>ant-junit</artifactId>
<version>1.8.0</version>
</dependency>
<dependency>
<groupId>org.apache.ant</groupId>
<artifactId>ant-trax</artifactId>
<version>1.8.0</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.1</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
<encoding>utf8</encoding>
</configuration>
</plugin>

用Maven运行后会自动生成单元测试报告,效果如下:

如何生成Junit报告的更多相关文章

  1. pytest 11 allure2生成html报告

    allure是一个report框架,支持java的Junit/testng等框架,当然也可以支持python的pytest框架,也可以集成到Jenkins上展示高大上的报告界面. 环境准备 1.pyt ...

  2. pytest文档13-allure2生成html报告(史上最详细)

    前言 allure是一个report框架,支持java的Junit/testng等框架,当然也可以支持python的pytest框架,也可以集成到Jenkins上展示高大上的报告界面. 环境准备 1. ...

  3. pytest十六:allure2 生成 html 报告

    allure 是一个 report 框架,支持 java 的 Junit/testng 等框架,当然也可以支持 python 的 pytest 框架,也可以集成到 Jenkins 上展示高大上的报告界 ...

  4. pytest生成allure报告

    在pytest框架中可以用很多插件来生成测试报告,本文总结下怎么生成allure报告 allure allure是一款开源的,专门用来展示测试结果的一个工具,allure可以与很多的测试框架做集成,比 ...

  5. pytest_allure2 生成html报告

    前言      allure是一个report框架,支持java的Junit/testng等框架,当然也可以支持python的pytest,也可以集成到Jenkins上展示高大上的报告界面. 环境准备 ...

  6. [转载]Matlab生成Word报告

    最近在进行一批来料的检验测试,一个个手动填写报告存图片太慢了,就有了种想要使用Matlab在分析完后数据可以自动生成PDF报告的想法,于是就去网上搜索了相关的资料,发现Matlab中文论坛上有xiez ...

  7. ORACLE AWR概述及生成AWR报告

    1.Overview of the Automatic Workload Repository The Automatic Workload Repository (AWR) collects, pr ...

  8. 生成awr报告

    主要参考文献: http://343766868.blog.163.com/blog/static/48314056201110124513396/ 概况 Oracle内部以一定的频率把系统关键的统计 ...

  9. 自动生成AWR报告

    --自动生成AWR报告 -------------------2013/09/23   脚本代码:   #!/bin/bash   AWR_FORMAT=html NUM_DAYS=1   MAX_S ...

随机推荐

  1. 【Vegas原创】VirtualBox扩容、分割的整体方案

    背景:在低压i7上跑vmware,卡顿无极限,决定转战virtual Box. 但是VirtualBox最讨厌的一点,就是vdi文件无法分割,平时习惯备份的我,百度网盘最大也就20G的上传.咋整? v ...

  2. CentOS7为php7.2安装php-redis扩展

    先下载phpredis-develop cd /tmpwget https://codeload.github.com/phpredis/phpredis/zip/develop 安装unzip.zi ...

  3. Nginx 学习专栏

    Nginx 入门学习教程 译:Centos7 编译安装Nginx 教程

  4. ubuntu 18.04 配置 rc.local

    ubuntu 18.04 配置 rc.local:https://blog.csdn.net/a912952381/article/details/81205095 Ubuntu /etc/rc.lo ...

  5. golang中值类型/指针类型的变量区别总结

    转自:https://segmentfault.com/a/1190000012329213 值类型的变量和指针类型的变量 先声明一个结构体: type T struct { Name string ...

  6. oracle去掉字符串中所有指定字符

    Select Replace(字段名,'指定字符','替换字符') From 表名 --例: select replace('de.5d','.','') from dual --显示结果:de5d ...

  7. 使用git命令push到自己的仓库,显示Unknown且没有贡献记录的解决方案

    一.问题的起因 今天用公司电脑在github上push时出现了以下问题: 用户名为unknown: 贡献记录为0: 二.解决方案 1,检查一遍自己的账号密码是否正确,如果正确,执行第二步骤操作: 2, ...

  8. Linux 正则表达式_010

    Linux 正则表达式 标注:本教程只针对linux运维的三剑客命令awk,sed,grep正则表达式 什么是正则表达式? 简单的说,正则表达式就是为处理大量的字符串而定义的一套规则和方法通过定义的这 ...

  9. log4j Tricks (log4j 1.2)

    1. 开启 log4j 框架内部的日志输出到控制台 # 在 log4j.properties 中添加log4j.debug=true # 配置 log4j 框架内部的日志通过 System.out 输 ...

  10. eclipse.ini 修改默认编码为 UTF-8

    eclipse.ini 修改默认编码为 UTF-8 打开您的eclipse安装目录,找到eclipse.ini文件 打开eclipse.ini文件,在最下面加入一行代码:-Dfile.encoding ...