Monday, July 22, 2019

PowerMock stubbing can help deal with subclasses of private classes

Today I needed to mock an inner class that was a subclass of a different, private inner class. Creating a mock or spy failed in the class initializer because the generated mock class didn't have access to the private superclass. However, using PowerMockito.stub on a PowerMockito.method representation of the method to replace worked.

No comments:

Post a Comment