@Test // Uses of JMockit API: 8 public void useArgumentMatchers() { new Expectations() { { // Using built-in matchers: mockedList.get(anyInt); result = "element"; // Using Hamcrest matchers: mockedList.get(withArgThat(is(equalTo(5)))); result = new IllegalArgumentException(); minTimes = 0; mockedList.contains(withArgThat(hasProperty("bytes"))); result = true; mockedList.containsAll(withArgThat(hasSize(2))); result = true; } }; assertEquals("element", mockedList.get(999)); assertTrue(mockedList.contains("abc")); assertTrue(mockedList.containsAll(asList("a", "b"))); new Verifications() { { mockedList.get(anyInt); } }; }