Mockito

Mocking a static or private method is often necessary when writing unit tests. However, before Mockito 3.4.0, it was impossible to explicitly mock static methods. Thus, PowerMock offers solutions to the defined use case. In this article, we will look at the introduction of PowerMock and explore examples of mocking private, static, and final methods.…

Read More A Guide to Mocking Private and Static Methods Using PowerMock

You will use @MockBean annotation to create and automatically add mocks to Spring ApplicationContext. In this tutorial, we will look at different ways you can use @MockBean annotation to create mocks. If you are testing your application with JUnit and Mockito, then there are many other useful tutorials you will find on the Testing Java Code…

Read More @MockBean Annotation Example

Earlier I’ve published a blog post on now to create a RESTful Web Service(JAX-RS) to accept JSON payload with user profile details and how to save user profile details into a MySQL database using Java Hibernate framework. In this blog post I am going to share with you how to test(using JUnit and Mockito) it’s Service…

Read More Test RESTful Web Service with JUnit and Mockito