This is a "standard" Quarkus project adapted from the Quarkus getting started guide.
A few highlights:
- shows how to run Karate via JUnit using the
@QuarkusTest
annotation - uses an injected
@TestHTTPResource
to get the URL after resolving the (dynamic) port that the Quarkus application is running on- in test mode,
quarkus.http.test-port=0
in src/test/java/application.properties configures the server to start on a random and unused port
- in test mode,
- the Karate script
greeting.feature
has two tests for each REST end-point - shows how the URL (including dynamic port number) is passed to Karate from the Quarkus environment in
GreetingTest.java
- Uses
<classifier>all</classifier>
in the Mavenpom.xml
to avoid conflicts with Quarkus dependencies- we also use
karate-core
instead ofkarate-junit5
as JUnit is brought in byquarkus-junit5
- we also use
- Uses the
quarkus-logging-logback
extension to bridge Karate with Quarkus' logging system- note the over-ride of the
ch.qos.logback:logback-classic
dependency since Quarkus requires a higher version
- note the over-ride of the
Quarkus heaviliy depends on Graal and so does Karate, so watch out for NoClassDefFoundError
or polyglot
in stack traces. You may need to adjust dependencies so that Karate works without issues. Refer to this thread for more details.
Run mvn test
to execute the JUnit test: GreetingTest.java