Best practice: Api test with several versions of client


(Karl-Johan Karlberg) #1

I have a RESTful service that is used during deploy. I hit the service by fireing off a small java program from the buildscript (this is bundled in a jar). Easy enough. I am about to do some refactoring on the api and I want to make sure I remain backward compatible on the server side…

Currently I run an integration test on my service that pulls a specific version of the “client jar” and I run what the main class would run and make some asserts. Still simple… Now I refactor the api and make changes in the client jar to use all the new fancy features. I now want to add more tests using the new fancy client jar while keeping the old one…

I can keep the tests in different source sets and hand pick the different cilent jars to each configuration but sooner or later I just have lots and lots of directories :slight_smile:

I can keep the old impl and just add new code in the client and call a different main and different set of methods, but that leaves old dirty code in the client…

The client jar will move from version 1.x to 2.x…

Any ideas?


(Luke Daley) #2

It’s a little bit hard to extract your requirements at this abstract level.

Perhaps try proposing some potential Gradle build script, even if it’s pseudo code in parts, then highlighting what you either don’t know how to do or what you’re not happy with.


(Karl-Johan Karlberg) #3

Thanks for the quick response.

Here is a quick example of what I can do (pseudo code)

configurations {
  integ_1_0 extends testRuntime
  integ_2_0 extends testRuntime
}
  //and similar source sets...
  dependecies {
...
  integ_1_0 'autoconf:autoconf:1.0'
  integ_2_0 'autoconf:autoconf:2.0'
}
ingeg_1_0test (type: Test) {
  compileClasspath = configurations.integ_1_0.asPath
}
  ingeg_2_0test (type: Test) {
  compileClasspath = configurations.integ_2_0.asPath
}

duplication delux :slight_smile:

Assume that I want to test against all trusted versions of my small helper jar I might want to do something similar to:

foreach version of dependant jar
{ jar ->
  executeTestclassOfVersion(jar.version)
}

My groovy skills need improvment for sure…


(Luke Daley) #4

So what you have there is the general approach I would follow.

Are you unsure how to factor this repetition out into a method like ‘executeTestclassOfVersion’?