Apache Camel provides great support for unit testing Camel routes on Blueprint, but testing multiple routes can be slow. By default, Camel will create and shutdown the CamelContext per test in your test class.
For example, a simple CBR Camel route with 6 tests takes ~13s to execute (~17s to build):
By overriding the isCreateCamelContextPerClass method from CamelTestSupport to return true in test class we can force camel to only create one CamelContext at the beginning instead of one per test.
If you override the method to return true CamelTestSupport will automatically reset any MockEndpoint in your routes before each test execution to ensure clean mock: endpoints.
Note: When using AdviceWith with isCreateCamelContextPerClass all mock: endpoints might not be reset correctly. You can use the @Before JUnit annotation to reset them: