PowerMock is an
open source testing framework to unit test Java applications. It is released
under the Apache License. Whereas PowerMock is an open source mocking library
that extends mocking frameworks like EasyMock, Mockito.
PowerMock provides two extension APIS.
a. For
EasyMock
b. For
Mockito
To use PowerMock,
a. we
require either EasyMock (or) Mockito
b. Test
frameworks like JUnit, TestNG
Currently PowerMock supports JUnit and TestNG. I am going
to use PowerMock, Mockito and Junit combination for this tutorial series. Most
of the mocking frameworks in Java can't mock private, static and final methods.
By using PowerMock, we can extend the frameworks like Mockito and can able to
mock private static methods.
I am going to use below maven dependencies.
<dependencies> <!-- https://mvnrepository.com/artifact/org.mockito/mockito-all --> <dependency> <groupId>org.mockito</groupId> <artifactId>mockito-all</artifactId> <version>1.10.19</version> <scope>test</scope> </dependency> <dependency> <groupId>org.powermock</groupId> <artifactId>powermock-module-junit4</artifactId> <version>1.7.3</version> <scope>test</scope> </dependency> <dependency> <groupId>org.powermock</groupId> <artifactId>powermock-api-mockito</artifactId> <version>1.7.3</version> <scope>test</scope> </dependency> </dependencies>
If you would like to learn EasyMock and PowerMock
tutorial series, you can go through my previous tutorial series.
No comments:
Post a Comment