Setting private fields of a class for unit testing

In this post under Powermock, I will with example show how to set private fields of a class for unit testing. For example, consider you have a class as shown below to be tested Class To Be Tested package package5; import java.util.Date; import java.util.Random; public class Example5 { private Random random = new Random(); public…… Continue reading Setting private fields of a class for unit testing

Mocking Static class methods

In Mockito we cannot mock static class methods, so we can use PowerMock which extends the Mockito features and provides its own features. One of which is mocking static class methods. Below code will give an example how to mock static class methods Calculator package package1; public class Calculator { public static int add(int value1,…… Continue reading Mocking Static class methods