Add to classpath for one specific unit test

I have some classpath-scanning logic I need to unit test. For such a test, I need to put a non-conforming class on the classpath and program the test to expect an exception.

All the common classpath scanners (Scannotations, Google Reflections, and JAX-RS Jersey (that I’m familiar with)) eventually parse the java.class.path System property to bootstrap class discovery.

From where I stand, I can see yaks being shaved… but is there a way I can configure my build to a) launch a separate JVM for each test (yes, there is a way iirc), and b) for one specific test class, put a non-conforming class on the JVM classpath?

Thanks.

You’ll need to declare a separate ‘Test’ task for that one specific test class.