Feb 14th, 2011, 09:05 AM
Supporting transaction Rollback for End-to-end testing
section 10.2 of the reference documentation provides an example for doing end-to-end tests using "JobLauncherTestUtils". The test consists of some data setup and then the job is launched. I've had some problems trying to run this with the @Transactional annotation, as ideally I'd like to rollback the data setup. In the meantime I've come across some threads which mention that a batch job cannot be run within a transaction. Is there a way to launch a job within a Transactional test?
Feb 17th, 2011, 03:44 AM
No. You will find plenty of threads discussing this problem. The short summary is that a Job in production is a complex interplay between multiple transactions, and it needs to keep control of that. It hasn't been worth it so far to provide an end-to-end transaction mode purely for test purposes. There are also JIRA issues open. If you want to take a crack at it, feel free.
Originally Posted by emallin