Why was integration tests using Spring Test framework designed to need @Transactional annotation in the @Test method by default?
Based on the documentation on Spring testing: https://docs.spring.io/spring-framework/reference/testing/testcontext-framework/tx.html#testcontext-tx-enabling-transactions Annotating a test method with @Transactional causes the test to be run within a transaction that is, by default, automatically rolled back after completion of the test. If a test class is annotated with @Transactional, each test method within that class hierarchy runs within a transaction. Test methods that are not annotated with @Transactional (at the class or method level) are not run within a transaction. @Transactional is needed in an integration test using Spring Test. This approach is good in that after the test all the update will be rolled back. Question: But the approach of adding @Transactional annotation to each test method doesn't test the persisted result. is this approach a true integration test at all?
Based on the documentation on Spring testing: https://docs.spring.io/spring-framework/reference/testing/testcontext-framework/tx.html#testcontext-tx-enabling-transactions
Annotating a test method with @Transactional causes the test to be run within a transaction that is, by default, automatically rolled back after completion of the test. If a test class is annotated with @Transactional, each test method within that class hierarchy runs within a transaction. Test methods that are not annotated with @Transactional (at the class or method level) are not run within a transaction.
@Transactional
is needed in an integration test using Spring Test. This approach is good in that after the test all the update will be rolled back.
Question: But the approach of adding @Transactional
annotation to each test method doesn't test the persisted result. is this approach a true integration test at all?