7

When I run an integration test of camel route processing as a standalone test, it passes. When I run all the tests, it fails with assertion errors of expected values. When I add @DirtiesContext to the abstract test class, they all pass ok.

I checked the docs and beyond the paragraph below, they do not say why @DirtiesContext is actually needed, and what goes wrong when not used.

Notice that we use @DirtiesContext on the test methods to force Spring Testing to automatically reload the CamelContext after each test method - this ensures that the tests don't clash with each other (e.g. one test method sending to an endpoint that is then reused in another test method).

The thing is that creating spring context again and again is quite time consuming. All our other non-camel integration tests pass without @DirtiesContext (using @Transactional) and we would like to continue with that.

Is there a way to put camel to pristine state without recreating the whole spring context so the test's MockEndpoints work as expected?

Kenster
  • 23,465
  • 21
  • 80
  • 106
redhead
  • 1,264
  • 1
  • 17
  • 32

0 Answers0