Using jMock from Maven Builds
jMock 2
The jMock 2 jars are accessible via Maven 2 by declaring the following dependencies in your POM. All the required dependencies on jMock core and Hamcrest will be included automatically.
To use jMock 2.5.1 with JUnit 3:
<dependency> <groupId>org.jmock</groupId> <artifactId>jmock-junit3</artifactId> <version>2.5.1</version> </dependency>
To use jMock 2.5.1 with JUnit 4:
<dependency> <groupId>org.jmock</groupId> <artifactId>jmock-junit4</artifactId> <version>2.5.1</version> </dependency>
Note: From jMock 2.4.0 onwards, the default JUnit 4 Maven
dependency is junit:junit-dep. This requires Maven's Surefire to be
configured to use it instead of the standard junit:junit dependency.
Versions of maven-surefire-plugin 2.3.1 and 2.4 support the optional
<junitArtifactName>junit:junit-dep</junitArtifactName>
configuration element.
To use jMock 2.5.1 to mock classes:
<dependency> <groupId>org.jmock</groupId> <artifactId>jmock-legacy</artifactId> <version>2.5.1</version> </dependency>
To use other versions of jMock, replace the contents of the version tags.
jMock 1
To use jMock 1.2.0 core:
<dependency> <groupId>jmock</groupId> <artifactId>jmock</artifactId> <version>1.2.0</version> </dependency>
To use the jMock 1.2.0 CGLIB extension:
<dependency> <groupId>jmock</groupId> <artifactId>jmock-cglib</artifactId> <version>1.2.0</version> </dependency>