rcasia / neotest-java

Neotest adapter for Java.
MIT License
44 stars 24 forks source link

Use JUnit Standalone for better performance #68

Closed rcasia closed 7 months ago

rcasia commented 11 months ago

Using mvn and gradle CLIs as build tools works, but it is slow especially for big projects.

I tried a different strategy that could be implemented instead:

#!/bin/bash

MVN_CLASSPATH=$(mvn -q dependency:build-classpath -Dmdep.outputFile=/dev/stdout)
CLASSPATH="./target/classes/:./target/test-classes/:$MVN_CLASSPATH"
STANDALONE_JAR="/home/user/Downloads/junit-platform-console-standalone-1.10.1.jar"

FILEPATH="./src/test/java/com/example/ExampleApplicationTests.java"
ARGS="-m=com.example.ExampleApplicationTests#test --reports-dir=tmp"

javac -d target -cp $CLASSPATH:$STANDALONE_JAR $FILEPATH &&
    java -jar $STANDALONE_JAR -cp $CLASSPATH $ARGS