What does the PowerMock’s suppress() method do?

What does the PowerMock’s suppress() method do?

A) Suppresses the execution of specific methods or constructors
B) Suppresses the creation of mock objects
C) Suppresses the test execution
D) Suppresses the logging of test results

Answer:

A) Suppresses the execution of specific methods or constructors

Explanation:

The suppress() method in PowerMock is used to suppress the execution of specific methods or constructors. This is useful when you want to avoid the side effects of certain methods or constructors during testing.

For example:


PowerMockito.suppress(PowerMockito.method(ClassWithConstructor.class, "constructorMethod"));

In this example, the suppress() method is used to suppress the execution of the constructor method in ClassWithConstructor.

Reference links:

https://www.javaguides.net/p/top-java-libraries.html

Scroll to Top