@Capturing: expectation recorded on method using type parameter from generic base type fails to match #252

rliesenfeld opened this Issue Jan 26, 2016 · 1 comment


None yet

2 participants


The following test fails:

public interface Base<T> { T doSomething(); }
static class Impl implements Base<Integer> { public Integer doSomething() { return 1; } }

public void captureImplementationsOfGenericType(@Capturing final Base<?> anyInstance)
    new Expectations() {{ anyInstance.doSomething(); result = 2; }};

    int result = new Impl().doSomething();

    assertEquals(2, result);

The implementation class gets mocked (as doSomething() returns zero), but the invocation fails to match the recorded expectation.

@rliesenfeld rliesenfeld added the bug label Jan 26, 2016
@rliesenfeld rliesenfeld self-assigned this Jan 26, 2016
nothize commented Jan 27, 2016

Do u have any idea if I may help to fix this issue as it helps me too?

@rliesenfeld rliesenfeld added a commit that referenced this issue Feb 21, 2016
@rliesenfeld rliesenfeld Added test for issue #252. 5d1a901
@rliesenfeld rliesenfeld added a commit that closed this issue Sep 12, 2016
@rliesenfeld rliesenfeld Added support for matching of generic methods recorded on @Capturing-…
…mocked subclasses of generic types; closes #252.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment