This is a "standard" Micronaut project adapted from the Micronaut getting started guide.
A few highlights:
- shows how to run Karate via JUnit using the
@MicronautTestannotation - uses an
@Inject-edEmbeddedServerto get the URL after resolving the (dynamic) port that the Micronaut application is running on- in test mode,
(server:) port: -1in src/test/java/application-test.yml configures the server to start on a random and unused port
- in test mode,
- the Karate script
hello.featurehas a test for the/helloend point - shows how the URL (including dynamic port number) is passed to Karate from the Micronaut environment in
HelloTest.java - Uses
<classifier>all</classifier>in the Mavenpom.xmlto avoid conflicts with Micronaut dependencies
Micronaut heavily depends on Graal and so does Karate which requires us to align the versions pulled in by the pom.xml. This is why we have the additional entries for org.graalvm.js:js-scriptengine and org.graalvm.js:js and we force them to be the version that Micronaut needs.
If you see the application hanging or things like a NoClassDefFoundError and polyglot or "graal" mentioned in the stack traces, you need to adjust this.
Run mvn test to execute the JUnit test: HelloTest.java