Skip to content
Advertisement

Quarkus tests fail while doing mocking with jmock resulting in “No code generation strategy available”

When running my Quarkus tests in combination with jmock I run into:

java.lang.IllegalStateException: No code generation strategy available

This is what I have setup jmock with:

@QuarkusTest
@Tag("integration")
class MyServiceTest {
    @RegisterExtension
    JUnit5Mockery mockery = new JUnit5Mockery() {
        {
            setImposteriser(ByteBuddyClassImposteriser.INSTANCE);
            setThreadingPolicy(new Synchroniser());
        }
    };

To make matters worse: This all works on the command line but not within Eclipse.

Advertisement

Answer

This is due to the JRE/JDK that Eclipse selects to run your tests. These tests should be run using a JDK only, the JRE that comes whith most versions of Eclipse will not service. So: install a full JDK (eg. by using sdkman) and specify & select that to run your tests in this part of the preferences of Eclipse: enter image description here

Advertisement