Skip to content

Instantly share code, notes, and snippets.

@mgryszko
Last active October 17, 2020 19:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mgryszko/2f0a0eee69f7e704e2b65c3b7ed8fb88 to your computer and use it in GitHub Desktop.
Save mgryszko/2f0a0eee69f7e704e2b65c3b7ed8fb88 to your computer and use it in GitHub Desktop.
Bad test helpers
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