Closed carojkov closed 1 month ago
I agree - it would be excellent to be able to mock. The only response I've gotten in the past from google devs (not protobuf, though) as to why the classes are marked final is because they wanted to ensure users of their libraries don't use inheritance on those classes.
That response feels like using a Nuke to remove the tree stump in the back yard to me. However, even that can be solved - using interfaces. Wasn't finding any common ground / interest in working on the matter, so I gave up.
As mentioned on #11162 follow-up, this request may belong on a gRPC project instead of this one. Sorry that I don't know the right project to link here myself.
Is this the plugin invloved? https://github.com/xolstice/protobuf-maven-plugin
Looking at the plugin briefly, I did not find references to the grpc/protobuf code generators themselves.
Hope this helps.
Yep, I think I posted to the wrong project. I'll make sure to re-post to the right one.
However, I think the design issue is systemic - unit tests should be able to mock generated classes. Even Any, Empty etc should be mockable but user classes should be mockable without question.
I agree that generated model objects should be inheritable (and, hence, not final
), although I can see protobuf folks wanting to be clear that subclasses aren't supported in the marshalling/unmarshalling (aka seralizing/deserializing). At least adding a "I know what I am doing - I swear" option to the generator that drops the final
keyword would be nice to have.
@carojkov if you @
me on any new threads, I'll try to help/contribute.
Thanks, I am sure adding voices makes a differenced.
We triage inactive PRs and issues in order to make it easier to find active work. If this issue should remain active or becomes active again, please add a comment.
This issue is labeled inactive
because the last activity was over 90 days ago. This issue will be closed and archived after 14 additional days without activity.
We triage inactive PRs and issues in order to make it easier to find active work. If this issue should remain active or becomes active again, please reopen it.
This issue was closed and archived because there has been no new activity in the 14 days since the inactive
label was added.
re: https://github.com/protocolbuffers/protobuf/issues/11162
Allow mocking stubs - don't make them final
I'd love to be able to mock stubs
@MarinaShaposhnikova @artnaseef