Crafting a test harness to compare a single API operation against two different API versions


I am interested in an elegant Gradle solution to a problem such as this:

I have an application that programs to an older version of JodaTime (JT). I want to upgrade to a new version of JT. I have isolated the calls my application makes to the old version of JT. I want to write concise tests in a wholly separate Gradle build that allows me to compare the result of an operation O against the old version of JodaTime to the same operation O against the new API.

Is there a clever way to craft a Gradle build so that I can run tests against the old version of JT, then the new version? This requires changing the testCompile classpath between tests.

Maybe I’m over thinking this, but the technique could come in handy in all manner of isolated testing of 3rd party libraries.


You just need to declare multiple ‘Test’ tasks whose ‘classpath’ you configure differently.

Thank you.

[Not a Gradle question/issue]: It also occurred to me that I could just stick with a classic build and in my @Test method simply load each version of the API from disk into its own classloader and go from there. Simpler, and admits comparing what needs comparing in the same method call/stackframe.