jamesnetherton opened a new issue, #9308:
URL: https://github.com/apache/camel-quarkus/issues/9308

   `CamelQuarkusTestSupport` is currently the only Camel specific test support 
for JVM mode tests. It requires extending a base class and overriding methods 
such as `createRouteBuilder()`, `isMockEndpoints()` and `doBeforeEach()`.
   
   Camel itself also offers annotation driven testing (`@CamelMainTest` in 
`camel-test-main-junit6`, `@CamelSpringBootTest` and its companion annotations 
in `camel-test-spring-junit6`), which has no equivalent on Camel Quarkus.
   
   It would be good to add an annotation based alternative to 
`camel-quarkus-junit`, alongside `CamelQuarkusTestSupport` and not replacing it:
   
   ```java
   @CamelQuarkusTest(routes = GreetingTest.Routes.class)
   class GreetingTest {
   
       @Inject
       ProducerTemplate template;
   
       @EndpointInject("mock:result")
       MockEndpoint result;
   
       @Test
       void greets() throws Exception {
           result.expectedBodiesReceived("Hello World");
           template.sendBody("direct:start", "World");
           result.assertIsSatisfied();
       }
   
       public static class Routes extends RouteBuilder {
           @Override
           public void configure() {
               from("direct:start").transform().simple("Hello 
${body}").to("mock:result");
           }
       }
   }
   ```
   
   Proposed scope:
   
   * `@CamelQuarkusTest`, implying `@QuarkusTest`, with attributes for test 
routes, advice (`@AdviceRoute`), `replaceRouteFromWith`, `mockEndpoints`, 
`mockEndpointsAndSkip`, `stubEndpoints`, `autoStartupExclude`, 
`dumpRouteCoverage`, `dumpRoute` and `shutdownTimeout`.
   * `@ReplaceInRegistry` and `@ProvidesBreakpoint` companion annotations.
   * An injectable `CamelTestHelper` for per test method operations such as 
`adviceRoute` and `getMockEndpoint`.
   * Everything declared on the annotation applies to the whole test class and 
is undone after its last test method.
   
   Because test classes are part of the application in `@QuarkusTest` mode, the 
annotation can be inspected at build time. That makes a few things possible 
that `CamelQuarkusTestSupport` cannot do:
   
   * Route builders declared for a test class are kept out of application route 
discovery, so they never leak into other test classes.
   * Invalid use fails the test build with a message naming the class, instead 
of failing or silently doing nothing at runtime.
   * Features that only work before routes are created (auto mocking, stubbing, 
breakpoints, auto startup exclusion) are restricted to test classes that own 
their application through a dedicated `@TestProfile`. Using them on a shared 
application fails the build.
   
   Applying those features before routes are created needs a hook into the 
Camel Main lifecycle of test applications. A small `ServiceLoader` SPI in 
`camel-quarkus-core`, only active in applications built for tests, would 
provide that without `camel-quarkus-junit` becoming an extension.
   
   JVM mode only, like `CamelQuarkusTestSupport`.
   
   Known limitation: Quarkus continuous testing only detects composed 
`@QuarkusTest` annotations that are declared in the test sources, so 
`@QuarkusTest` has to be added next to `@CamelQuarkusTest` there.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to