I think this is the answer:
task testJar(type: Jar) { classifier = 'tests' from sourceSets.test.output }