-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Closed
Closed
Copy link
Labels
status: waiting-for-triageIssues that we did not analyse yetIssues that we did not analyse yettype: feature
Description
It will be cool if there is an ability to revert changes produced from Spring batch job in test.
I tried to test some job or single step and found that typical Spring approach with idempotent tests using @Transactional doesn't work here. Even if transaction attributes were provided to support existing transaction and validateTransactionState is disabled.
So i would like to use it somehow like this
Expected Behavior
@Test
@Rollback
@Transactional
void Should_create_batches_for_existing_payments() throws Exception {
testInvoiceGenerator.generateInvoicesForBatch(invoicesCount);
var expectedCreatedBatchCount = invoicesCount / batchSize;
var jobExecution = jobLauncherTestUtils.launchJob();
int countPaymentBatchCount = countPaymentBatchCount();
assertThat(jobExecution.getStatus()).isEqualTo(COMPLETED);
assertThat(countPaymentBatchCount).isEqualTo(expectedCreatedBatchCount);
}Current Behavior
There is no way to revert commits made by Spring batch transaction manager, or override transaction behaviour in tests.
Context
Spring batch test
Metadata
Metadata
Assignees
Labels
status: waiting-for-triageIssues that we did not analyse yetIssues that we did not analyse yettype: feature