'Quarkus Karate Test Error: Could not find option with name engine.WarnInterpreterOnly

I want to Test my Endpoints using Karate, but when starting the Test I get following Error:

java.lang.IllegalArgumentException: Could not find option with name engine.WarnInterpreterOnly.

Java version: 11

Karate Maven Dependency:

<dependency>
  <groupId>com.intuit.karate</groupId>
  <artifactId>karate-junit5</artifactId>
  <version>1.2.0.RC4</version>
</dependency> 

Feature File:

Feature: To test the config-resource

  Background:
    * url baseUrl

  Scenario: Add a new room
    Given path 'addRoom/testRoom'
    When method POST
    Then status 201 

Java Test class:

package at.htl.mqtt.client.boundary;

import com.intuit.karate.junit5.Karate;
import io.quarkus.test.junit.QuarkusTest;

@QuarkusTest
public class ConfigEndpointTest {

    @Karate.Test
    Karate testGetRoom() {
        return Karate.run("config-resource.feature").relativeTo(getClass());
    }
}

I have src/test/java as my testResource

Edit:

So I used the Runner API like you said but I still get the same Error.

import io.quarkus.test.junit.QuarkusTest;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;

@QuarkusTest
public class ConfigEndpointTest {

    @Test
    void testRoom() {
        Results results = Runner.path("config-resource.feature").relativeTo(getClass()).parallel(5);
        assertEquals(0,results.getFailCount(), results.getErrorMessages());
    }
}

Btw I changed Java version to 16.

Any other suggestions?



Solution 1:[1]

I have a feeling the @Karate.Test annotation does not "play well" with the @QuarkusTest one.

So I recommend using the Runner API. You can find an explanation here: https://stackoverflow.com/a/65578167/143475

I am not sure if you still need a method annotated with @Test etc, please follow the Quarkus instructions that are appropriate.

Solution 2:[2]

I'm not sure about this specific Exception. I got this one

superclass access check failed: class com.oracle.truffle.polyglot.PolyglotImpl (in unnamed module @0x40729f01) cannot access class org.graalvm.polyglot.impl.AbstractPolyglotImpl (in module org.graalvm.sdk) because module org.graalvm.sdk does not export org.graalvm.polyglot.impl to unnamed module @0x40729f01
java.lang.IllegalAccessError: superclass access check failed: class com.oracle.truffle.polyglot.PolyglotImpl (in unnamed module @0x40729f01) cannot access class org.graalvm.polyglot.impl.AbstractPolyglotImpl (in module org.graalvm.sdk) because module org.graalvm.sdk does not export org.graalvm.polyglot.impl to unnamed module @0x40729f01

But what worked for me was to use @QuarkusIntegrationTest instead of @QuarkusTest. Also for whatever reason my tests would only run on GraalVM (I tried Azul, OpenJDK and Temurin neither of which worked). These are on Java 17

As far as I know @QuarkusIntegrationTest runs the application in an isolated process (even going as far as running the docker image created with quarkus.container-image.build is true) as opposed to @QuarkusTest which doesn't as a result letting us modify the context, inject mocks etc. When using @QuarkusIntegrationTest the application is only accessible via network calls.

There's also some caveats when it comes to running both of these tests in a single execution according to this.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Peter Thomas
Solution 2 Venkatesh Prasad Kannan