Skip to content

Instantly share code, notes, and snippets.

@SDiamante13
Last active March 12, 2020 14:20
Show Gist options
  • Select an option

  • Save SDiamante13/06b51ff0193927b54d06c655e75e9124 to your computer and use it in GitHub Desktop.

Select an option

Save SDiamante13/06b51ff0193927b54d06c655e75e9124 to your computer and use it in GitHub Desktop.
Example on how to use Mockito's verify
@Test
public void saveCustomer_savesTheCustomerToTheDatabase() {
// Arrange
Customer customer = new Customer(123, "Sam");
// Act
Customer result = customerService.saveCustomer(customer);
// Assert
verify(mockCustomerRepository, times(1))
.save(customer);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment