I would like to configure Maven Surefire to always fork a new JVM process for each test and reload all .class files that are necessary within that test inside that newly forked process.
I thought this was realizable with forkCount=1 and reuseForks=false (for maximal isolation of tests), but this does not work, as tests (i.e., JVM forks) will not reload a .class file if it has already been loaded by a previously run test.
I've tried using the isolated class loader rather than the system class loader, but that did not affect this problem.
Right now I'm starting my test execution like this: mvn test -DfailIfNoTests=false -Dmaven.test.failure.ignore=true -DforkCount=1 -DreuseForks=false -f PATH_TO_PROJECT.
Thank you.
EDIT: My desired behavior seems to be the default on Surefire 2.19.1. Unfortunately, other things break with JDK>=11 with Surefire 2.19.1. I have not figured out what has changed since then, but would appreciate hints on that.