JiriOndrusek commented on code in PR #3847:
URL: https://github.com/apache/camel-quarkus/pull/3847#discussion_r922070988
##########
docs/modules/ROOT/pages/user-guide/testing.adoc:
##########
@@ -226,3 +226,27 @@ class MyTest {
----
More examples of WireMock usage can be found in the Camel Quarkus integration
test source tree such as
https://github.com/apache/camel-quarkus/tree/main/integration-tests/geocoder[Geocoder].
+
+== `CamelTestSupport` style of testing
+
+If you used plain Camel before, you may know
https://camel.apache.org/components/latest/others/test-junit5.html[CamelTestSupport]
already.
+Unfortunately the Camel variant won't work on Quarkus and so we prepared a
replacement called `CamelQuarkusTestSupport`, which can be used in JVM mode.
+
+There are several limitations:
+
+* Test has to be annotated by `@QuarkusTest` and has to extend
`CamelQuarkusTestSupport`.
+* Quarkus runs tests in a custom classloader which JUnit is not aware of (see
the
https://quarkus.io/guides/getting-started-testing#applying-interceptors-to-tests[documentation]).
If JUnit's callback (i.e.
`org.junit.jupiter.api.extension.BeforeEachCallback`) is used, it may not work
as expected. Use the quarkus callbacks instead (see the
https://quarkus.io/guides/getting-started-testing#enrichment-via-quarkustestcallback[documentation])
or use annotations like `@org.junit.jupiter.api.BeforeEach`.
+* Camel Quarkus lifecycle does not allow to start/stop Camel context. Context
is started before execution of the first test and closed after the finish of
the last one. Test has to be written with consideration with this limitation.
If it is not possible to write a test with such limitation, `@TestProfile` has
to be used. Test profile forces quarkus to restart its engine, therefore it
creates a new Camel context (see the
https://quarkus.io/guides/getting-started-testing#testing_different_profiles/[documentation]
about this feature).
+The `CamelQuarkusTestSupport` implements `QuarkusTestProfile`, therefore the
test class could be used as a value for `@TestProfile`.
+* Camel Quarkus executes the production of beans during the build phase.
Because all the tests are
+build together, exclusion behavior is implemented into
`CamelQuarkusTestSupport`. If a producer of the specific type and name is used
in one tests, the instance will be the same for the rest of the tests.
+
+[source,java]
+----
+@QuarkusTest
+@TestProfile(SimpleTest.class) //necessary only if "newly created" context is
required for the test (worse performance)
+public class SimpleTest extends CamelQuarkusTestSupport {
+ ...
+}
+----
+
Review Comment:
I added this information into the doc before list of limitations.
--
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]