Skip to content

Instantly share code, notes, and snippets.

@jelford
Last active December 22, 2015 10:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jelford/6461525 to your computer and use it in GitHub Desktop.
Save jelford/6461525 to your computer and use it in GitHub Desktop.
This will bite you if you use Guava's ImmutableX types.
public class AppTest
{
@Rule public JUnitRuleMockery context = new JUnitRuleMockery();
public static interface ColGetter {
public abstract Col get();
}
public static interface NonColGetter {
public abstract NonCol get();
}
@Test
public void cantDoCollection() {
final ColGetter icut = context.mock(ColGetter.class);
context.checking(new Expectations() {{
oneOf(icut).get();
will(returnValue(null));
}});
icut.get();
}
@Test
public void canDoNonCollection() {
final NonColGetter icut = context.mock(NonColGetter.class);
context.checking(new Expectations() {{
oneOf(icut).get();
will(returnValue(null));
}});
icut.get();
}
public abstract class Col implements Collection {
}
public abstract class NonCol {
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment