Write a class that verifies if the class you want to use is loaded (will need to be a separate class due to how classloaders work. it will be something like
public class OODetector {
public static boolean isOOOnClassPath() {
try {
OODetector.class.getClassLoader().loadClass("org.... class name here ...");
return true;
} catch (Throwable t) {
return false;
}
}
}
Now at the start of any test that requires the class on the classpath, just put Assume.assumeThat(OODetector.isOOOnClassPath(), is(true));
and your test will be skipped in such cases, e.g.
public class OOTests {
@Test
public void smokes() throws Exception {
Assume.assumeThat(OODetector.isOOOnClassPath(), is(true));
// rest of test
}
}
or better yet, put it in the @BeforeClass, e.g.
public class OOTests {
@BeforeClass
public static void smokes() throws Exception {
Assume.assumeThat(OODetector.isOOOnClassPath(), is(true));
}
// tests
}
That will skip all the tests in the class if OO is not on the classpath, does not affect failed count, but keeps the total test count valid, and when you figure out the correct way to get the runtime dependencies onto your Maven-launched test classpath then the tests will magically start running