Which PowerMock class is used to verify that a static method was called?

Which PowerMock class is used to verify that a static method was called?

A) PowerMockito.verifyStatic()
B) PowerMockito.verify()
C) PowerMockito.checkStatic()
D) PowerMockito.check()

Answer:

A) PowerMockito.verifyStatic()

Explanation:

The PowerMockito.verifyStatic() method is used to verify that a static method was called during the test execution. It works similarly to verifying regular method calls but is specifically designed for static methods.

For example:


PowerMockito.verifyStatic(ClassWithStaticMethods.class);
ClassWithStaticMethods.staticMethod();

In this example, the verifyStatic() method verifies that the static method staticMethod() in ClassWithStaticMethods was called.

Reference links:

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

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top