JUnit

Difference between Mockito’s when/thenReturn and doReturn/when

A common dilemma while writing unit tests in Java is whether to use Mockito’s when/thenReturn or doReturn/when stubbings. Both when/thenReturn and doReturn/when are used in Mockito, a popular Java testing framework, to mock behavior of methods in an object. However, they are used in slightly different scenarios. when/thenReturn is used to mock the return value… read more »

How to Use OpenGPT to Write JUnit Tests

Test driven development is the standard nowadays but sometimes somehow there appears a class before the test is written. This is especially true for legacy projects and legacy code. The most unpleasant task in such moments is to write the JUnit tests. That’s when OpenGPT comes to help. You just paste the class to OpenGPT… read more »

How to Create a Simple Mockito Unit Test

Mockito is a popular Java framework which comes to great help in Unit testing. In Unit testing it’s important to get to a state where you can concentrate on testing a specific functionality or behaviour. Mockito can help you with this by mocking or simulating specific methods which you may need. It’s important to be… read more »

Sidebar