Top "Powermock" questions

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

Mock a constructor with parameter

I have a class as below: public class A { public A(String test) { bla bla bla } public String check() { bla …

java junit mocking mockito powermock
PowerMockito mock single static method and return object

I want to mock a static method m1 from a class which contains 2 static methods, m1 and m2. And I …

java jakarta-ee mockito easymock powermock
How to mock private method for testing using PowerMock?

I have a class which I would like to test with a public method that calls private one. I'd like …

java testing junit mockito powermock
Mocking Logger and LoggerFactory with PowerMock and Mockito

I have the following Logger I want to mock out, but to validate log entries are getting called, not for …

java junit mockito slf4j powermock
How do I mock a static method that returns void with PowerMock?

I have a few static util methods in my project, some of them just pass or throw an exception. There …

static mocking mockito void powermock
Mockito + PowerMock LinkageError while mocking system class

I've got such a code snippet: @RunWith(PowerMockRunner.class) @PrepareForTest({Thread.class}) public class AllMeasuresDataTest { @Before public void setUp() throws …

java mockito junit4 powermock linkageerror
Using PowerMockito.whenNew() is not getting mocked and original method is called

I have a code somewhat like this below: Class A { public boolean myMethod(someargs) { MyQueryClass query = new MyQueryClass(); Long id = …

java junit mockito powermock
Mock static methods from multiple class using PowerMock

I know how to mock static methods from a class using PowerMock. But I want to mock static methods from …

java junit4 powermock
PowerMock testing - set static field of class

I'm having difficulty finding a way to set a static field of a class. It's basically like this: public class …

junit static mocking powermock
Which Maven artifacts should I use to import PowerMock?

What jars do I need to add to my pom.xml to get PowerMock working with Mockito? I have the …

java maven mockito powermock