Last active
March 6, 2020 02:21
-
-
Save SDiamante13/f8cf75cbb9587c16781e43bbf49b12a7 to your computer and use it in GitHub Desktop.
An example on how to setup what a mock returns using BDD syntax.
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() { | |
| // Given | |
| given(mockCustomerRepository.findById(123L)) | |
| .willReturn(new Customer(123, "Sam")); | |
| // When | |
| Customer result = customerService.getCustomerById(123); | |
| // Then | |
| assertThat(result.name).isEqualTo("Sam"); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment