title: How to mock Class.forName and class.Constructor.newInstance()
body: <p>i have been trying to mock </p>
  
  <pre><code>clazz = Class.forName("Complete Class path") 
  Object obj = clazz.Constructor().getInstance();
  </code></pre>
  
  <p>I googled it, and found links which informed how to mock the static method using powermock. I tried using those logic to mock the </p>
  
  <p><code>Class.forName("Complete Class path")</code></p>
  
  <p>and </p>
  
  <p><code>Object obj = clazz.Constructor().getInstance()</code> but have been facing errors.</p>
  
  <pre><code>at sun.reflect.GeneratedSerializationConstructorAccessor16.newInstance(Unknown Source) [junit]
  at java.lang.reflect.Constructor.newInstance(Constructor.java:423) [junit] 
  at org.objenesis.instantiator.sun.SunReflectionFactoryInstantiator.newInstance(SunReflectionFactoryInstantiator.java:45) [junit]
  at org.powermock.reflect.internal.WhiteboxImpl.newInstance(WhiteboxImpl.java:223) [junit]
  at org.powermock.reflect.Whitebox.newInstance(Whitebox.java:139) [junit]
  at org.powermock.api.mockito.internal.mockcreation.MockCreator.mock(MockCreator.java:64) [junit]
  at org.powermock.api.mockito.PowerMockito.mock(PowerMockito.java:203) [junit]
  at org.powermock.api.extension.listener.AnnotationEnabler.standardInject(AnnotationEnabler.java:106) [junit]
  at org.powermock.api.extension.listener.AnnotationEnabler.beforeTestMethod(AnnotationEnabler.java:54) [junit]
  at org.powermock.tests.utils.impl.PowerMockTestNotifierImpl.notifyBeforeTestMethod(PowerMockTestNotifierImpl.java:90) [junit]
  at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl$PowerMockJUnit44MethodRunner.executeTest(PowerMockJUnit44RunnerDelegateImpl.java:292) [junit]
  at org.powermock.modules.junit4.internal.impl.PowerMockJUnit47RunnerDelegateImpl$PowerMockJUnit47MethodRunner.executeTestInSuper(PowerMockJUnit47RunnerDelegateImpl.java:127) [junit]
  at org.powermock.modules.junit4.internal.impl.PowerMockJUnit47RunnerDelegateImpl$PowerMockJUnit47MethodRunner.executeTest(PowerMockJUnit47RunnerDelegateImpl.java:82) [junit]
  at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl$PowerMockJUnit44MethodRunner.runBeforesThenTestThenAfters(PowerMockJUnit44RunnerDelegateImpl.java:282) [junit]
  at org.junit.internal.runners.MethodRoadie.runTest(MethodRoadie.java:87) [junit]
  at org.junit.internal.runners.MethodRoadie.run(MethodRoadie.java:50) [junit]
  at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl.invokeTestMethod(PowerMockJUnit44RunnerDelegateImpl.java:207) [junit]
  at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl.runMethods(PowerMockJUnit44RunnerDelegateImpl.java:146) [junit]
  at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl$1.run(PowerMockJUnit44RunnerDelegateImpl.java:120) [junit]
  at org.junit.internal.runners.ClassRoadie.runUnprotected(ClassRoadie.java:34) [junit]
  at org.junit.internal.runners.ClassRoadie.runProtected(ClassRoadie.java:44) [junit]
  at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl.run(PowerMockJUnit44RunnerDelegateImpl.java:122) [junit]
  at org.powermock.modules.junit4.common.internal.impl.JUnit4TestSuiteChunkerImpl.run(JUnit4TestSuiteChunkerImpl.java:106) [junit]
  at org.powermock.modules.junit4.common.internal.impl.AbstractCommonPowerMockRunner.run(AbstractCommonPowerMockRunner.java:53)
  </code></pre>