-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Use with Maven
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
See Maven Surefire plugin and Maven Failsafe Plugin.
Up until now there were two Maven artifacts for JUnit: junit:junit-dep
and junit:junit
. From a Maven point-of-view only the former made sense because it did not contain the Hamcrest classes but declared a dependency to the Hamcrest Maven artifact. The latter included the Hamcrest classes which was very un-Maven-like.
From this release (4.11) on, you should use junit:junit
which will be what junit:junit-dep
used to. If you still reference junit:junit-dep
, Maven will automatically relocate you to the new junit:junit
and issue a warning for you to fix.
In your pom.xml
, declare dependency used as junit-dep
, and also override transitive dependency to hamcrest-core
, so you can use Hamcrest full library of matchers:
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-core</artifactId>
<version>1.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit-dep</artifactId>
<version>4.10</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-library</artifactId>
<version>1.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>1.9.0</version>
<scope>test</scope>
</dependency>
The following one-liner described here.
Reports on the test times, slowest sorted to the top:
$ grep -h "<testcase" `find . -iname "TEST-*.xml"` | sed 's/<testcase name="\(.*\)" classname="\(.*\)" time="\(.*\)".*/\3\t\2.\1/' | sort -rn | head