In the end I wrote my own, loosely based on another Stack Overflow answer (which didn't work for me).
It's now on GitHub, and Maven Central.
https://github.com/BinaryTweed/quarantining-test-runner
<dependency>
<groupId>com.binarytweed</groupId>
<artifactId>quarantining-test-runner</artifactId>
<version>0.0.1</version>
</dependency>
To use it annotate your test classes accordingly:
@RunWith(QuarantiningRunner.class)
@Quarantine({"com.binarytweed"})
public class MyIsolatedTest {
...
The linked answer didn't work for me as the test class itself needs to be loaded in a separate ClassLoader
, as then all the classes it references will use the same loader. Quarantining is inclusive (rather than exclusive) as you need the JUnit @Test
annotations to be loaded by the parent ClassLoader
, otherwise JUnit can't find any testable methods as it uses Class<Test>
as a key in a lookup map.