Description
Description
I noticed that there is a test class SimpleSampler extends production class SamplerBase to assist testing nextDouble(), nextInt(), nextInt(int) and nextLong(). This might not be the best priactice in unit testing and can be improved by leveraging mocking frameworks.
Current Implementation
- SimpleSampler implements SamplerBase and overrides methods to call super methods defined in parent class.
- In test case, the child test class is used to test methods in parent class SamplerBase.
Proposed Implementation
- Replace SimpleSampler with a mocking object created by Mockito.
- Use method stub to control the behavior of the mocking object.
- Create a method to return the mocking object for reusing.
Motivation
- Decouple test class SimpleSampler from production class SamplerBase.
- Remove the redundant test child class SimpleSampler