This week's book giveaway is in the OCPJP forum. We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates 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