Last active
March 6, 2020 02:15
-
-
Save SDiamante13/2607e721351a1b23f0b08a418c93556d to your computer and use it in GitHub Desktop.
An example on how to setup what a mock returns.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @Test | |
| public void getCustomerById_returnsCorrectCustomer_whenGivenValidId() { | |
| // Arrange | |
| when(mockCustomerRepository.findById(123)) | |
| .thenReturn(new Customer(123, "Sam")); | |
| // Act | |
| Customer result = customerService.getCustomerById(123); | |
| // Assert | |
| assertThat(result.name).isEqualTo("Sam"); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment