CODEC-303: Refactor NoOpBaseNCodec to improve test logic#94
CODEC-303: Refactor NoOpBaseNCodec to improve test logic#94wx930910 wants to merge 1 commit intoapache:masterfrom
Conversation
|
We can also get rid of the method that return the mocking object and directly create the mocking object inside of each test case. |
|
While this seems like a clever use of Mockito, it hinders ease of understanding the code and maintenance IMO. Mocking is a great technique for certain use cases, this isn't one of them IMO. The current noop adapter is clear, simple, and can be stepped into while debugging if needed. |
|
@garydgregory, thanks for providing the feedback! What do you think about this case, do you think we will get benefit from Mockito by replacing the inheritance with spying object? IMO It seems like the only reason we use inheritance is because we cannot directly create an instance from abstract class. |
|
Using Mockito here I feel falls under the old adage "Once you have a hammer, everything starts to look like a nail." The class in question is an abstract class and therefore cannot be instantiated, the proper use case is subclassing, both for an app and therefore for a test. Using Mockito to avoid using a concrete subclass only obfuscates what the test is trying to do, makes the code harder to maintain and to learn as you are now requiring new users and maintainers to learn Mockito on top of learning the code base. |
|
@garydgregory I see, thank you so much for providing such detailed feedback! |
|
Closing per comments. |
Jira
Description
Replace test class NoOpBaseNCodec by mocking object and improve test design
Motivation
NoOpBaseNCodecfrom production classBaseNCodec.Key changed/added classes in this PR
NoOpBaseNCodec, decoupled test from production code.NoOpBaseNCodec.