Created
September 4, 2011 05:02
-
-
Save savagematt/1192295 to your computer and use it in GitHub Desktop.
First time!!!
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package au.com.sheep; | |
import org.hamcrest.Matcher; | |
import org.junit.Test; | |
import org.mockito.Matchers; | |
import java.util.List; | |
import static au.com.sheep.MockitoMatcherRecorder.record; | |
import static org.hamcrest.MatcherAssert.assertThat; | |
import static org.hamcrest.Matchers.is; | |
import static org.hamcrest.Matchers.not; | |
import static org.mockito.Matchers.contains; | |
import static org.mockito.Matchers.eq; | |
public class MockitoMatcherRecorderTest { | |
@Test | |
public void should() { | |
record(TestClass.class).method(contains("sheep"), eq(42)); | |
List<Matcher> recorded = MockitoMatcherRecorder.matchers.get(); | |
assertThat( | |
recorded.size(), | |
is(2) | |
); | |
assertThat( | |
"something about sheep", | |
recorded.get(0) | |
); | |
assertThat( | |
"something about pigs", | |
not(recorded.get(0)) | |
); | |
assertThat( | |
42, | |
recorded.get(1) | |
); | |
assertThat( | |
23, | |
not(recorded.get(1)) | |
); | |
} | |
private static class TestClass{ | |
public void method(String sheep, Integer cheese){ | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment