如何生成Junit报告
前言: 对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报告的更多相关文章
- pytest 11 allure2生成html报告
allure是一个report框架,支持java的Junit/testng等框架,当然也可以支持python的pytest框架,也可以集成到Jenkins上展示高大上的报告界面. 环境准备 1.pyt ...
- pytest文档13-allure2生成html报告(史上最详细)
前言 allure是一个report框架,支持java的Junit/testng等框架,当然也可以支持python的pytest框架,也可以集成到Jenkins上展示高大上的报告界面. 环境准备 1. ...
- pytest十六:allure2 生成 html 报告
allure 是一个 report 框架,支持 java 的 Junit/testng 等框架,当然也可以支持 python 的 pytest 框架,也可以集成到 Jenkins 上展示高大上的报告界 ...
- pytest生成allure报告
在pytest框架中可以用很多插件来生成测试报告,本文总结下怎么生成allure报告 allure allure是一款开源的,专门用来展示测试结果的一个工具,allure可以与很多的测试框架做集成,比 ...
- pytest_allure2 生成html报告
前言 allure是一个report框架,支持java的Junit/testng等框架,当然也可以支持python的pytest,也可以集成到Jenkins上展示高大上的报告界面. 环境准备 ...
- [转载]Matlab生成Word报告
最近在进行一批来料的检验测试,一个个手动填写报告存图片太慢了,就有了种想要使用Matlab在分析完后数据可以自动生成PDF报告的想法,于是就去网上搜索了相关的资料,发现Matlab中文论坛上有xiez ...
- ORACLE AWR概述及生成AWR报告
1.Overview of the Automatic Workload Repository The Automatic Workload Repository (AWR) collects, pr ...
- 生成awr报告
主要参考文献: http://343766868.blog.163.com/blog/static/48314056201110124513396/ 概况 Oracle内部以一定的频率把系统关键的统计 ...
- 自动生成AWR报告
--自动生成AWR报告 -------------------2013/09/23 脚本代码: #!/bin/bash AWR_FORMAT=html NUM_DAYS=1 MAX_S ...
随机推荐
- 修复android 5.0 Xutils的框架问题retry error, curr request is null
Android 5.0手机对xUtils-2.6.13.jar请求时会出现retry error, curr request is null 情况, 修复解决方式: 找到library/src/com ...
- why-the-default-authentication-hadoop-is-unsecured ?
https://www.learningjournal.guru/article/hadoop/hadoop-security-using-kerberos/ https://stackoverflo ...
- 《FPGA全程进阶---实战演练》之搞定阻抗匹配
笔者最近几天在做视频采集板卡时,视频显示端打算采用 USB2.0接口+上位机 显示,其中USB需要做阻抗匹配.通常情况下USB的阻抗值需要做到90Ω±10%.下面就讲解一下关于阻抗匹配的知识,哪里说得 ...
- [tomcat启动报错]registered the JDBC driver [com.alibaba.druid.proxy.DruidDriver] but failed to unregister it when the web application was stopped
环境:一个tomcat ,一个工程配置了多数据源,在启动的时候报如下错误: SEVERE: The web application [/qdp-resource-job] registered the ...
- SpringBoot 全配置(推荐收藏)
# =================================================================== # COMMON SPRING BOOT PROPERTIE ...
- minicom for Mac 配置
安装:brew install minicom 配置: 串口是:dev/tty.usbserial minicons -s 配置一下: 流控要关掉,不然输入不了
- python 记录linux网速到文件。
import timefrom app.utils_ydf import LogManager logger = LogManager('network_monitor').get_logger_an ...
- Sqlalchemy model 文件自动生成
自动生成Sqlalchemy的models文件的包早用过了,有个字段类型做了改动,调了得10几分钟才搞定.记录下自动生成models文件的python包sqlacodegen sqlacodegen已 ...
- 【Linux常用工具】
tmux - 终端分屏工具 man - Help cat/more/less - 文件阅读 less还具有字符串搜索功能
- 《Go语言网络编程》第一章:体系
原书地址:http://tumregels.github.io/Network-Programming-with-Go 如果不知道想要构建什么,是不可能创建一个系统的.而且如果不知道它工作的环境,也同 ...