How to write junit for private methods using mockito
What you will learn here about Junit
- How to write junit for private methods using mockito
How to write junit for private methods using mockito
Please follow the following steps to know how to write junit for private methods using mockito.
1)First create a simple maven project
2)Add power mock dependency in your pom.xml which is given below
<dependency> <groupId>org.powermock</groupId> <artifactId>powermock-module-junit4</artifactId> <version>2.0.9</version> <scope>test</scope> </dependency>
3)Create a class with private methods which is shown below
4)Now write junit for covering private methods using power mock which is shown below
For covering private methods we need to use Whitebox .invokeMethod of power mock which is shown below