Top "Powermock" questions

Use this tag for questions about PowerMock, a Java library for creating mock objects for classes and methods.

PowerMock: How to unmock a method?

I have a static method that is mocked using PowerMock to throw an exception. (It deletes files.) Unfortunately, during my @…

java testing powermock
Mockito cannot mock this class: interface

I'm having an issue with mockito and powermock, I can mock an abstract class with a final static method with …

java-8 mockito powermock powermockito
Mock Spring Component

I am using Mockito to mock spring beans. It works fine when I mock an interface. In our application, there …

mocking mockito powermock spring-test powermockito
Mock objects in Junit test gives NoClassDefFoundError

When I mock objects in Junit test cases using of PowerMock and Mockito, I'm getting this exception: java.lang.NoClassDefFoundError: …

java junit mockito powermock
PowerMock: Using Whitebox.invokeMethod(...) properly for a method taking an Object[] as a param

private boolean isEmpty(Object[] array) { if (array == null || array.length == 0) return true; for (int i = 0; i < array.length; i++) { …

java unit-testing junit powermock white-box
Using PowerMock with Spock

I have a class with a few static methods.I need to Mock these static methods. I know PowerMock does …

groovy powermock spock
Mocking Joda DateTime method using Mockito

I want millis to return specified value. public long myMethod(){ DateTime nowDateTime = new DateTime(DateTimeZone.UTC); long millis = nowDateTime.getMillis(); …

java mockito powermock
Can I mock a superclass's constructor with Mockito/Powermock?

Is it possible using Mockito and optionally Powermock to mock a superclass S such that any calls to the superclass …

java inheritance mockito superclass powermock
PowerMockito. Mock static method. why does not PowerMockito#stub work?

I want to mock only one static method in class, all other methods should work like real object. code: public …

java unit-testing mockito powermock stubbing
java.lang.NoSuchMethodError powermock

Guys Question: How to mock a static final class which has defined some other static final class? Problem Description: When …

java junit easymock powermock jmock