Top "Powermockito" questions

Use this tag for questions about PowerMockito, a Java Framework that allows the mocking of usually un-mockable types, i.e. statics, and private methods, in conjunction with the Mockito framework.

Mockito: Mock private field initialization

How I can mock a field variable which is being initialized inline? class Test { private Person person = new Person(); ... public …

java mockito junit4 powermockito
Mock Static Methods in JUnit5 using PowerMockito

Need help for Mocking Static methods using JUnit5 with PowerMockito framework. Powermock junit5 and mockito2.x not working RunnerTestSuiteChunker not …

java junit5 powermockito junit5-extension-model
mocking protected method

I want to mock an inherited protected method. I can't call this method directly from java code as it is …

java mockito powermock powermockito
checked exception is invalid for this method

I have the below class There is an answer to this in StackOverflow but it deals with List throw checked …

java junit mockito powermockito
PowerMockito mocking static method fails when calling method on parameter

I'm trying to test a class which uses a calculator class with a number of static methods. I've successfully mocked …

java unit-testing powermockito
PowerMockito.verifyStatic() Problems

I need to use PowerMockito to test if a specific static method is called. I am using the following PowerMockito …

java junit powermockito
@RunWith(PowerMockRunner.class) vs @RunWith(MockitoJUnitRunner.class)

In the usual mocking with @Mock and @InjectMocks annotations, the class under testing should be run with @RunWith(MockitoJUnitRunner.class). @…

java mocking mockito powermockito
How can I mock an instance of an enum class with PowerMock & Mockito?

I tried to follow the example offered in the answer to this very similar question, but it does not work …

java enums mockito powermock powermockito
Mock static method with GroovyMock or similar in Spock

First-timer here, apologies if I've missed anything. I'm hoping to get around a call to a static method using Spock. …

unit-testing groovy spock powermock powermockito
Powermock static final method in final class

The Test case I am writing for: public class AClassUnderTest { // This test class has a method call public Long methodUnderTest() { // …

java unit-testing powermockito