Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mockit.internal.expectations.invocation.ExpectedInvocation#isMatchingGenericMethod don't match method name as isMatchingMethod did #715

Closed
4 tasks done
Nick-The-Uncharted opened this issue Sep 1, 2021 · 2 comments

Comments

@Nick-The-Uncharted
Copy link

Nick-The-Uncharted commented Sep 1, 2021

Please provide the following information:

  • Version of JMockit that was used:
    1.48
  • Description of the problem or enhancement request:

When instanced called is a subclass of mocking instance, and called method has a generic signature, mockit.internal.expectations.invocation.ExpectedInvocation#isMatchingGenericMethod will only match signature (return type and params type).

  • Check the following:
  • If a defect or unexpected result, JMockit project members should be able to reproduce it.
    For that, include an example test (perhaps accompanied by a Maven/Gradle build script) which
    can be executed without changes and reproduces the failure.

  • If an enhancement or new feature request, it should be justified by an example test
    demonstrating the validity and usefulness of the desired enhancement or new feature.

  • The issue does not fall outside the scope of the project (for example, attempting to use
    JMockit APIs from Groovy or Scala code, or with an Android runtime).

  • The JDK where the problem occurs is a final release, not a development build.

Snippet to reproduce it:

public class GenericTest {
    public static class ClassWithGenericMethod {
        public List<String> m() {
            return null;
        }

        public List<Integer> m2() {
            return null;
        }
    }

    @Test
    public void test(@Capturing ClassWithGenericMethod classWithGenericMethod) {
        new Expectations() {
            {
                classWithGenericMethod.m();
                result = Collections.singletonList("hello");
            }
        };
        System.out.println(new ClassWithGenericMethod(){}.m2()); // prints "[hello]"
    }
}
@Saljack
Copy link

Saljack commented Sep 1, 2021

I think this is the same issue as #708 . You can try to use PR #712 and check if it helps you.

@Nick-The-Uncharted
Copy link
Author

@Saljack Thank you, this fixed my problem. I am suprised this mr still haven't been merged....

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants