Using Jmock annotations with Junit 4

Recent versions of JMock have support for configuration by annotation using JUnit 4 MethodRule

package mypackage;
import org.jmock.integration.junit4.JUnitRuleMockery;
import org.junit.Rule;
import org.junit.Test;
public class TestMyClass {
   @Rule public final JUnitRuleMockery context = new JUnitRuleMockery();
   @Mock private MyCollaborator collaborator;
   @Test public void somethingHappensWhenSomethingElse() {

Leave a Reply

Your email address will not be published. Required fields are marked *