Mocking getClass method with PowerMockito
问题 I'd like to avoid mocking the getClass() method for a class but cannot seem to find any way around it. I'm trying to test a class that stores objects class types in a HashMap to a particular method to be used later. A brief example of this is: public class ClassToTest { /** Map that will be populated with objects during constructor */ private Map<Class<?>, Method> map = new HashMap<Class<?>, Method>(); ClassToTest() { /* Loop through methods in ClassToTest and if they return a boolean and