This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
The problem is folow:
I need to test some public method which is calling private static method. To test them separately I want to mock the second one.
PowerMock has method to expect call of private static. Also we can mock selected method of object with and it works for simple private methods.
But how can I make my tested obj to call mocked class method instead of its reall class method?
Make the private static method public and non-static. Seriously. Why would you not?
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Joined: Aug 01, 2009
Unfortunately I have no permissions to change this brainfack code. It's a legacy system. But I've found a solution. Perhaps it would be useful for somebody
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
subject: mocking private static methods with PowerMock