I'm writing unit test (using TestNG) for a static method. When mocking the class of the static method I'm getting an exception.
@RunWith(PowerMockRunner.class)
@PrepareForTest(TempClass.class)
public class MyTestClass {
@Test
public void testMethodt() {
PowerMockito.mockStatic(TempClass.class);
}
}
public class TempClass {
public static String getName(String name){
return "Hi " + name;
}
}
When execute PowerMockito.mockStatic(TempClass.class);
i'm getting following exception
org.powermock.api.mockito.ClassNotPreparedException:
[Ljava.lang.Object;@65466a6a
The class com.test.TempClass not prepared for test
Any solution for this?