For a long while I’ve been looking forward to mocking void methods, I always thought that would be fairly impossible. After a long search online I’ve found it how to do it. So this example is from my work, it is a simple dummy method which creates a user on a 3rd party system. import
Now a days while I discover TDD and testing in software development, I’ve come to realize that it is also possible to test exceptions in Junit as well. I’ve noticed this while I was checking a code snippet of a software online and right after that I’ve tested the same thing to see the outcome.
For a long while i have been having this crazy incident in Spring transaction which cause me headaches while conducting tests for backend development. The Issue i face is that I’ve dozen of test methods which test different functionality of my Database methods, firstly creation methods are being conducted and I do carry out other
I was looking for a way to test Java file apis, especially I’ve such methods which return Java File. I somehow felt that those methods also have to be tested at least a small test case could be conducted. I did check what File api returns at Oracle Api Docs. The Method you’ll observe below
If you are mocking a database dao and would like to mock a method which returns a list of objects, you can create objects in Arrays as list and mock it example shown below when(dbService.getPersonnel(personnelNumber)).thenReturn( Arrays.asList(new Object(), new Object()));
In this post roll, I’d like to show how to combine Spring, JUnit and Mockito to test a target application. Simply mocking in my definition is to set dummy data for DAO objects. The target source may have accurate data for us to test depending on given data set, in this case where the mocking