powermock+mockito+testng 单元测试pom文件
0:Supported versions
PowerMock version 1.7.0 and upper has experimental support of Mockito 2.
A lot of issues are not resolved still. PowerMock uses internal Mockito API, but at least it possible to use both mocking framework together.
PowerMock team working on full Mockito 2 with Mockito team. (#726, #mockito/1110)

1:PowerMock+Mockito+Junit4.4 -Above
<properties>
<powermock.version>1.7.1</powermock.version>
</properties>
<dependencies>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-module-junit4</artifactId>
<version>${powermock.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-api-mockito2</artifactId>
<version>${powermock.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
2:PowerMock+Mockito+TestNG
<properties>
<powermock.version>1.7.1</powermock.version>
</properties>
<dependencies>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-module-testng</artifactId>
<version>${powermock.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-api-mockito2</artifactId>
<version>${powermock.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
3:Demo Project
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.xxx.unittest</groupId>
<artifactId>xxxTest</artifactId>
<version>0.1.0</version>
<packaging>jar</packaging>
<name>xxxTest</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<powermock.version>1.7.1</powermock.version>
<jacoco.version>0.7.9</jacoco.version>
<surefireArgLine>
-javaagent:${settings.localRepository}/org/jacoco/org.jacoco.agent/${jacoco.version}/org.jacoco.agent-${jacoco.version}-runtime.jar=destfile=${project.build.directory}/jacoco.exec
</surefireArgLine>
</properties>
<parent>
<groupId>com.xxx.project</groupId>
<artifactId>ParentPom</artifactId>
<version>4.0.0</version>
</parent>
<dependencies>
<!--storm public package && demo
<dependency>
<groupId>com.xxx.service</groupId>
<artifactId>xxxStormTools</artifactId>
<version>0.1.3</version>
</dependency>
-->
<!-- NoClassDefFoundError: com/google/inject/Injector -->
<dependency>
<groupId>com.google.inject</groupId>
<artifactId>guice</artifactId>
<version>4.1.0</version>
</dependency>
<!--powermock && mockito &&testng-->
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-module-testng</artifactId>
<version>${powermock.version}</version>
<!--<scope>test</scope>-->
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-api-mockito2</artifactId>
<version>${powermock.version}</version>
<!--<scope>test</scope>-->
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-module-testng-agent</artifactId>
<version>1.7.1</version>
<!--<scope>test</scope>-->
</dependency>
<dependency>
<groupId>org.uncommons</groupId>
<artifactId>reportng</artifactId>
<version>1.1.4</version>
</dependency>
<!--jacoco-->
<dependency>
<groupId>org.jacoco</groupId>
<artifactId>org.jacoco.agent</artifactId>
<version>0.7.9</version>
</dependency>
<dependency>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>${jacoco.version}</version>
</dependency>
<!--jcommander -->
<dependency>
<groupId>com.beust</groupId>
<artifactId>jcommander</artifactId>
<version>1.72</version>
</dependency>
</dependencies>
<build>
<testSourceDirectory>src/test/java</testSourceDirectory>
<resources>
<resource>
<directory>src/test/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
<plugins>
<!--jacoco-->
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>${jacoco.version}</version>
<executions>
<execution>
<id>pre-unit-test</id>
<goals>
<goal>prepare-agent</goal>
</goals>
<configuration>
<!-- Sets the path to the file which contains the execution data. -->
<destFile>${project.build.directory}/jacoco.exec</destFile>
<!--Sets the name of the property containing the settings for JaCoCo runtime agent.-->
<propertyName>surefireArgLine</propertyName>
</configuration>
</execution>
<execution>
<id>post-unit-test</id>
<phase>test</phase>
<goals>
<goal>report</goal>
</goals>
<configuration>
<dataFile>${project.build.directory}/jacoco.exec</dataFile>
<!-- Sets the output directory for the code coverage report. -->
<!--<outputDirectory>${project.reporting.outputDirectory}/jacoco-ut</outputDirectory>-->
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<!-- 经过测试 maven-compiler-plugin 插件版本请使用3.3,否则在jenkins上无法执行测试 -->
<version>3.7.0</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.6</version>
<configuration>
<encoding>${project.build.sourceEncoding}</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19</version>
<configuration>
<!--必须添加,否则不能生成jacoco覆盖率的报告-->
<testFailureIgnore>true</testFailureIgnore>
<!-- 解决用maven执行test时 日志乱码的问题,详见:http://www.cnblogs.com/discuss/archive/2010/10/27/1862225.html -->
<argLine>-Dfile.encoding=UTF-8</argLine>
<!--java8则需要添加-noverify配置-->
<argLine>-noverify ${surefireArgLine}
-javaagent:${settings.localRepository}/org/powermock/powermock-module-javaagent/${powermock.version}/powermock-module-javaagent-${powermock.version}.jar
</argLine>
<systemPropertyVariables>
<jacoco-agent.destfile>${project.build.directory}/jacoco.exec</jacoco-agent.destfile>
</systemPropertyVariables>
<properties>
<!--<property>
<name>listener</name>
<value>com.xxx.unittest.plugins.htmlReporter.TestReportListener</value>
</property>-->
<!-- 这个设置让2个suite xml并行执行 -->
<property>
<name>suitethreadpoolsize</name>
<value>1</value>
</property>
<property>
<name>usedefaultlisteners</name>
<value>false</value>
</property>
</properties>
<suiteXmlFiles>
<suiteXmlFile>src/test/resources/testng.xml</suiteXmlFile>
</suiteXmlFiles>
<!--定义maven运行测试生成的报表路径 -->
<reportsDirectory>target/test-output</reportsDirectory>
</configuration>
</plugin>
<!--
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
<version>2.7</version>
</plugin>
-->
</plugins>
</build>
</project>
powermock+mockito+testng 单元测试pom文件的更多相关文章
- Spring Boot系列(一) Spring Boot介绍和基础POM文件
Spring Boot是由Pivotal团队提供的全新框架,其设计目的是用来简化新Spring应用的初始搭建以及开发过程.该框架使用了特定的方式来进行配置,从而使开发人员不再需要定义样板化的配置.通过 ...
- 基于maven的spring-boot的pom文件详解
Spring Boot 推荐的基础 POM 文件 名称 说明 spring-boot-starter 核心 POM,包含自动配置支持.日志库和对 YAML 配置文件的支持. spring-boot-s ...
- Spring Boot - 基础 POM 文件
表 1. Spring Boot 推荐的基础 POM 文件 名称 说明 spring-boot-starter 核心 POM,包含自动配置支持.日志库和对 YAML 配置文件的支持. spring-b ...
- 自动配置pom文件,构建maven项目jar包依赖关系,找到jar包运用到jmeter
首先说下pom文件特别方便的优点: 什么是pom文件? POM(Project Object Model) 是Maven的基础. 它是一个XML文件,包含了Maven用来build项目所需要的项目配置 ...
- maven pom文件
setting.xml主要用于配置maven的运行环境等一系列通用的属性,是全局级别的配置文件:而pom.xml主要描述了项目的maven坐标,依赖关系,开发者需要遵循的规则,缺陷管理系统,组织和li ...
- 工具类。父类(Pom文件)
ego_parent(pom文件) <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="ht ...
- maven pom文件详解
http://www.blogjava.net/hellxoul/archive/2013/05/16/399345.html http://blog.csdn.net/houpengfei111/a ...
- jenkins通过maven指定testng的xml文件,并给testng代码传参
1.jenkins设置参数化构建,设置要传的参数名和值 2.指定testng的xml文件,在jenkins的输入以下 3.在pom.xml文件分别引用jenkins的参数,设置两个property & ...
- Apache Maven pom文件
Welcome to Apache Maven Apache Maven is a software project management and comprehension tool. Based ...
随机推荐
- openshift 容器云从入门到崩溃之二《准备环境》
openshift 从3.9开始就开始支持系统组件在容器里运行了,之前版本都是直接运行在操作系统上,名字也改了叫OKD 目前最新的稳定版本是3.11,所以就安装3.11版本 准备环境: 主机名 系统 ...
- 2018-2019-1 20189221《Linux内核原理与分析》第五周作业
2018-2019-1 20189221<Linux内核原理与分析>第五周作业 实验四 实验过程 当用户态进程调用一个系统调用时,cpu切换到内核态并开始执行一个内核函数. 在Linux中 ...
- iOS 新浪微博-5.1 首页微博列表_时间/配图
在上一篇中,我们已经把首页微博显示出来了,但还有很多细节,需要我们去调整的.这一章中,我们将处理好时间,配图,工具框及转发微博等小细节的功能. 时间处理 第一步:定义一个时间的类别,用于判断是昨天.今 ...
- Ubuntu下orbbec mini 无法正常显示图像问题
最近用orbbec的深度摄像头采集RGBD图像,Windows下一切OK.但是Ubuntu下出现了不少问题.总结一下 1.将设备插到USB,先确定电脑能否正常识别设备 Ubuntu下是不需要安装驱动的 ...
- cocos2d JS 鼠标响应事件
对于PC和超级本,添加鼠标事件的的处理,可以加强用户的体验,其处理逻辑与触摸事件基本一样,多了一些鼠标特有的事件响应 如滚轮事件(onMouseScroll) cc.eventManager.addL ...
- 强力上攻后,缓解期结束,MACD死叉的案例
eg1.顶部,MACD收紧,缓解期刚过,正好下M5,触发减仓条件
- node.js初识04
node的Get表单提交 form.html <!DOCTYPE html> <html lang="en"> <head> <meta ...
- 编写一种递归方法,它返回数N的二进制中表示1的个数。
/** * 编写一种递归方法,它返回数N的二进制中表示1的个数.利用这样一个事实:N为奇数,其1的个数为N/2的二进制中1的个数加1. * @author wulei * */public class ...
- es6generator
yield语句 由于Generator函数返回的遍历器对象,只有调用next方法才会遍历下一个内部状态,所以其实提供了一种可以暂停执行的函数.yield语句就是暂停标志. yield语句只能用在 Ge ...
- div上下左右居中方法
方法一:在浏览器中只有一个div的情况 { position:fixed; position:fixed; ; ; ; ; margin:auto; } 方法一 方法二:一个父元素div和一个已知宽度 ...