In this post under Mockito, I will show with example the purpose of “@InjectMocks” annotation. In the previous post, I showed with example, the purpose of “@Mock” annotation. For recap “@Mock” annotation is used to instruct Mockito framework to create a mock of an object and assign it to variable. We write unit test class…… Continue reading Using @InjectMocks annotation
Category: Mockito
Using @Mock annotation
In my previous post under Mockito, I showed you with example how to manually create a mock. In this post under Mockito, I will show with example how to tell Mockito to create a mock and assign the reference to a variable. To tell Mockito framework to create a mock of a class and assign…… Continue reading Using @Mock annotation
Creating a mock
In this post under Mockito, I will show with example how to create a mock of a class. For our example I will use the “Calculator” class with below structure. Calculator package package1; public class Calculator { public int add(int x, int y) { return x + y; } public int multiple(int x, int y)…… Continue reading Creating a mock