This post originated from an RSS feed registered with Java Buzz
by Arpit Mandliya.
Original Post: Mockito Mock static method
Feed Title: Java tutorial for beginners
Feed URL: http://feeds.feedburner.com/arpitmandliyasblog
Feed Description: A blog about java programming language and its frameworks
In this post, we will see about Mockito Mock static method. If you want to mock static methods, you need to use PowerMockito.PowerMockito is capable of testing private, final or static methods as it makes use of Java Reflection API. Let’s create a simple example to mock static method using powermockito. 1. Create a simple java maven project. 2. Adding Dependencies with Maven Let’s add PowerMock dependencies to our maven project. Your pom.xml will look like below: Now that we are done adding dependencies, let’s enable the use of annotations in our tests. 3. Enabling PowerMock Annotations Just like