Mockito with JUnit
When you write/used to write test cases for your newly added function in your program, you may have come to the point where you realize the input for this function depends on the output of another program or system or resources, like http, database call etc. and we can not make the call because it is for tests. right? Calling real resources does not make sense either, or will you maintain all of these just to pass the tests you have written? Obviously not. Here comes Mockito handy, with Mockito you can mock all most everything, and write codes to return object you wanted to. <!-- https://mvnrepository.com/artifact/org.mockito/mockito-junit-jupiter --> < dependency > < groupId >org.mockito</ groupId > < artifactId >mockito-junit-jupiter</ artifactId > < version >4.5.1</ version > < scope >test</ scope > </ dependency > Lets go through example to understand its working better. Lets say, I have a socket...