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

Evaluate simplification of tests by making them @Transactional #11

Open christophknabe opened 6 years ago

christophknabe commented 6 years ago

Up to now we call CleanupService before and after each test method. The CleanupService deletes all entities from the persistence. It seems, that a simpler implementation is possible, as mentioned in https://docs.spring.io/spring/docs/current/spring-framework-reference/testing.html#testcontext-tx By annotating a test class with @Transactional, all methods in it are executed in a transaction and automatically rolled back after method completion.