Mockito verify is an impressive tool used in testing and there are various functionalities that would allow a developer to test method invocations.

Test number of invocations of a method

verify(mockedObject, times(1)).someMethod(); would test if someMethod() was called exactly 1 time.

verify(mockedObject, never()).someMethod(); would test if someMethod() was never called.

Test order of invocation

InOrder inOrder = Mockito.inOrder(mockedObject);        inOrder.verify(mockedObject).firstMethod();        inOrder.verify(mockedObject).secondMethod();

The…

Hi all!

Parameterized tests are extremely useful when you need to test a series of inputs against the same functionality. JUnit offers Parameterized class that facilitates this purpose.

As usual, let’s go through an example.

Assume you have a simple add method that takes 2 Integers and returns their sum…

Sachithra Dangalla

Software Engineer at Atlassian

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store