# Why we need PowerMock?

Although Mockito is most popular Mocking Library for Java Developers, But there are certain cases where Simple Mockito does not work. For Example, if your codebase uses any Singleton, you cannot mock them with Simple Mockito.

There are many other use cases, such as:

1. Mock Static Methods
2. Mock Final Classes and Methods
3. Inject mock for object creation with `whenNew()`
4. `suppress()`, `stub()` or `replace()` any method of a Class.
5. Suppress static initialisation.
6. Invoke private methods.
7. Inject field with `WhiteBox`


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://notes.tejpratapsingh.com/_/java-testing/powermockito/why-we-need-powermock.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
