Details
-
Improvement
-
Status: Closed
-
Minor
-
Resolution: Not A Problem
-
None
-
None
Description
Description
I noticed that there is a test class DummyInternalVersion implements a production interface InternalVersion to assist testing production constructor VersionIteratorImpl::VersionIteratorImpl(Session, InternalVersion). This might not be the best priactice in unit testing and can be improved by leveraging mocking frameworks.
Current Implementation
- DummyInternalVersion implements InternalVersion, creates two variables id and successors to control the behavior of method getId() and getSuccessors().
- Impelements other redundant methods and make them return null.
Proposed Implementation
- Replace DummyInternalVersion with a mocking object created by Mockito.
- Use method stub to control the behavior of getId() and getSuccessors() in the mocking object.
- Ignore the redundant methods to make test logic more clear.
- Create a method to return the mocking object for reuse purpose.
Motivation
- Decoupling test class DummyInternalVersion from production interface InternalVersion.
- Making test condition more clear by removing all redundant overridden methods.
- Making test logic more clear by using method stub instead of method overriding.