-
Notifications
You must be signed in to change notification settings - Fork 238
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
Unsupported fake for private method #714
Comments
I too would like to have tha abbility back to mock private methods. In my case these private methods are mocked in order to reduce complexity of test cases. |
It would be great if ability to mock private class and methods brought back. In my case all java classes and methods are private. Therefore we request to put private class/ method mocking back. If there there is any alternative please share, or Like ondrejlerch mentioned at least disable it by default and enable it somehow via JMockit API if you find it dangerous. Thanks in advance. |
From JMockit 1.47 it is not possible to mock private methods, such attempt leads to "Unsupported fake for private method" exception,
We find private method mocking useful in a situation when we call third party libraries out of our control.
E.g. We are using spring-ws and want to check what kind of soap request was actually sent. With JMockit <= 1.46 we have used:
Obviously WebServiceTemplate code is out of our control:
https://github.com/spring-projects/spring-ws/blob/main/spring-ws-core/src/main/java/org/springframework/ws/client/core/WebServiceTemplate.java#L626
JMockit was a great mocking tool for such corner cases and it allowed us to mock anything, including private methods of third party libraries.
We have been happily using JMockit for a long time on many projects and now we are stuck with 1.46 since we don't want to investigate how to replace all our private method mocks with some protected or public counterparts which is not straightforward, desirable or even possible.
Therefore we suggest to put private method mocking back. Or at least disable it by default and enable it somehow via JMockit API if you find it dangerous.
PS: We have noticed that JMockit was not released since 2019. We would be happy if this project continues since we find it great.
Many thanks ✌
The text was updated successfully, but these errors were encountered: