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.