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

Partial mocking on superclass is not consistent depending on method signature #384

Closed
phylexx opened this Issue Jan 17, 2017 · 0 comments

Comments

2 participants
@phylexx

phylexx commented Jan 17, 2017

  • Version of JMockit that was used:
    1.24 & 1.30

  • Description of the problem:
    Given the following three classes :
    ** Parent
    ** ChilA extends Parent
    ** ChildB extends Parent
    When partial mocking an instance of ChildA,
    Then method calls to Parent class using an instance of ChildB does not always proceed to real implementation, it depends on the method signature.

See the attached test case (using junit 4.x and jmockit 1.30).
InconsistentPartialMockingTest.zip

When ExpectedInvocation.getDefaultValueForReturnType return a not null object, no cascadingValue is returned in RecordAndReplayExecution.defaultReturnValue and the real implementation is called after exiting recordOrReplay.
When ExpectedInvocation.getDefaultValueForReturnType return a null object, and RecordAndReplayExecution.defaultReturnValue will get a cascadedValue and real implementation will not be called while exiting recordOrReplay.

In other words, when JMockit knows how to instantiate a defaultReturnValue for the called method, the real implementation is not called, otherwise it returns Void.class and real implementation is called.

I would expect that the real implementation is called on a non mocked instance/class when calling a method in its superclass whatever its prototype.

@phylexx phylexx changed the title from Partial mocking on superclass is not consistent according to method generic signature to Partial mocking on superclass is not consistent according to method signature Jan 17, 2017

@phylexx phylexx changed the title from Partial mocking on superclass is not consistent according to method signature to Partial mocking on superclass is not consistent depending on method signature Jan 17, 2017

@rliesenfeld rliesenfeld added the bug label Jan 21, 2017

@rliesenfeld rliesenfeld self-assigned this Jan 21, 2017

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