-
Notifications
You must be signed in to change notification settings - Fork 2
Testing
Philippe Marschall edited this page Mar 19, 2017
·
3 revisions
Stored procedure interfaces can easily used in testing without requiring database access. You can either use stubbing or mocking.
Given an interface
public interface TaxProcedures {
BigDecimal salesTax(BigDecimal subtotal);
}
You can simply implement the interface for tests.
public class StubTaxProcedures implements TaxProcedures {
public BigDecimal salesTax(BigDecimal subtotal) {
return subtotal.multiply(new BigDecimal("0.06"));
}
}
Or you can use a mocking framework like Mockito
TaxProcedures procedures = mock(TaxProcedures.class);
when(procedures.salesTax(any())).thenReturn(new BigDecimal("6.01"));
-
Usage
-
Integration