Skip to content

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:

class MyServiceTest {
    JUnit5Mockery mockery = new JUnit5Mockery() {
            setThreadingPolicy(new Synchroniser());

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



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