Usage and Idioms——Use with Maven

参阅  Maven Surefire plugin :http://maven.apache.org/plugins/maven-surefire-plugin/

参阅  Maven Failsafe Plugin : http://maven.apache.org/surefire/maven-failsafe-plugin/

Maven 依赖:

<dependency>
  <groupId>junit</groupId>
  <artifactId>junit</artifactId>
  <version>4.12</version>
  <scope>test</scope>
</dependency> 

在Maven中应用JUnitHamcrest

JUnit 4.11及以后版本:目前为止JUnit 有2个Maven 工具包,即 junit:junit-dep junit:junit 。就Maven的角度,前者不包含Hamcrest类并且它声明了对Hamcrest Maven 工具包的依赖,显然前者有意义;后者包括了和Maven 没什么共同点的Hamcrest类。

从JUnit 4.11 开始,你应该只用junit:junit 以代替过去的 junit:junit-dep 。如果你仍然用 junit:junit-dep,Maven会自动将你引导到新的 junit:junit  然后发出一个待修复的警告。

JUnit 4.10及较早版本: 在你的pom.xml,声明依赖使用as junit-dep,并且重写传递性依赖hamcrest-core,然后你可以使用Hamcrest的完整的匹配器库。

在Surefire xml output中找出最慢的测试:

一行描述如下:$ grep -h "<testcase" `find . -iname "TEST-*.xml"` | sed 's/<testcase time="(.*)" classname="(.*)" name="(.*)".*/1 2.3/' | sort -rn | head

 
原文地址:https://www.cnblogs.com/insist8089/p/6424981.html