christophknabe / spring-ddd-bank

A sample project following Domain Driven Design with Spring Data JPA
GNU Lesser General Public License v2.1
509 stars 125 forks source link

Increase Code Coverage in Exception Handlers by Mock Repositories #24

Closed christophknabe closed 2 years ago

christophknabe commented 2 years ago

In class domain.Client in method deposit the exception chaining code in line 121 is not executed by the test suite. In order to be able to throw an exception in the body of method deposit the AccountRepository should be mocked. We should use Mockito for this purpose.

christophknabe commented 2 years ago

Done in ClientTest.whenDepositFails_thenCauseShouldBeContainedInDepositFailure(). Additionally the code coverage in the domain package is increased to 100% by adding more test cases.