convention based on requirement/feature/behavior class PayInvoiceFeatureTest { class MarkInvoiceAsProcessedFeatureTest { class CreateInvoiceTemplateFeatureTest { class ProcessInvoiceFeatureTest { class AddInvoiceLineFeatureTest {
Identifier> resolvedIdentifiers = resolver.resolve(fields); assertThat(resolvedIdentifiers).containsKey("TIN"); } Let your test document the full story avoiding layers or abstractions
var fields = Map.of( validId, "586-547-145", "SSN", "6589-8745-1547" ) Map<String, Identifier> resolvedIdentifiers = resolver.resolve(fields); assertThat(resolvedIdentifiers).containsKey(validId); } Let your test document the full story avoiding layers or abstractions
Amount.EUR(100), Tax.vatPercentage(21)), new InvoiceItem("Product B", Amount.EUR(100), Tax.vatPercentage(21))) .build(); <Invoice> Limit your factory methods, override what matters with setters InvoiceMother.validInvoice() .withShippingAddress(address -> address.country(Country.US)) .build() Emphasize what matters and hide the irrelevant details
Tax.vatPercentage(21)), new InvoiceItem("Product B", Amount.EUR(100), Tax.vatPercentage(21))) .build(); // when var amount = invoice.getVatAmount(); // then assertThat(amount).isEqualTo(Amount.EUR(42)) Emphasize what matters and hide the irrelevant details
super(invoice, InvoiceAssertions.class); } public static InvoiceAssertions assertThat(Invoice invoice) { return new InvoiceAssertions(invoice); } public InvoiceAssertions isPaid() { Assertions.assertThat(actual.isPaid()) .withFailMessage("Expecting invoice to be paid but was not.") .isTrue(); return this; } }
B", Amount.euro(100.00), Tax.vatPercentage(21))) .build(); // when var amount = invoice.getVATAmount(); // then assertThat(invoice).hasAVatAmountOf(Amount.euro(42.00))