Last active
October 17, 2020 19:58
-
-
Save mgryszko/2f0a0eee69f7e704e2b65c3b7ed8fb88 to your computer and use it in GitHub Desktop.
Bad test helpers
This file contains 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
Invoice invoice; | |
@BeforeEach | |
void setup() { | |
createInvoiceToSave(); | |
} | |
@Test | |
void standardInvoice() { | |
mockCustomerFinder(); | |
createInvoiceUseCase.create(12345, new BigDecimal(100)); | |
assertInvoiceSaved(); | |
} | |
void mockCustomerFinder() { | |
when(authenticatedCustomerFinder.apply()).thenReturn(new Customer("Marcin", "Gryszko")); | |
} | |
void createInvoiceToSave() { | |
var customer = new Customer("Marcin", "Gryszko"); | |
invoice = new Invoice(12345, new BigDecimal(100), customer); | |
} | |
void assertInvoiceSaved() { | |
verify(invoiceRepository.save(invoice)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment