Search code examples
javajunit5junit-runnerjqwik

Run jqwik tests with Jupiter console launcher


For testing purposes (no pun intended) I run some tests outside the IDE or MAven using the Console Launcher that comes with JUnit Jupiter. It finds all the JUnit 4 (aka. Vintage) and JUnit 5 (aka. Jupiter) tests.

However, it does not discover my jqwik tests.

What I tried: In a Maven project, invoken mvn test-compile dependency:copy-dependencies, then in the target folder:

java -jar …/junit-platform-console-standalone-1.2.0.jar -cp classes -cp test-classes -cp $(echo dependencies/* | tr ' ' :) -p example

This incantation will run Jupiter and Vintage, but not jqwik, while the Surefire run does.


Solution

  • This works fine, if done correctly (user error on my side). To use the console launches in any project (well, Maven project (well, single-module Maven project)), you can use the following incantations:

    mvn clean test-compile dependency:copy-dependencies
    java -jar junit-platform-console-standalone-1.2.0.jar \
            -cp target/classes -cp target/test-classes \
            -cp $(echo target/dependency/* | tr ' ' :) \
            --scan-class-path target/test-classes
    

    Instead of the final --scan-class-path option you may wish to use other selectors like -p for a certain package; or add -e jqwik to choose only the jqwik tests.