Test task and NO_SOURCE

I am trying to figure out how to configure a Test task to execute tests, but keep getting NO_SOURCE as the outcome.

I’ve been told that the “sources” it is looking for are the test .java files. In my project, there really are no source as in .java files. The tests to execute are obtained as a transformation of test classes from another project.

So first, can anyone explain to me why the Test task requires the .java files in the first place? That is completely counter-intuitive. It does not compile them… that would be the compileTestJava task. So why does it need to know about them? Why is the “source” for Test not simply the test classes?

Beyond that, how do I actually set the sources to avoid the NO_SOURCE outcome? I set the test.testClassesDir and test.inputs, which does not seem to be enough. So I tried copying over the .java files from the “source project” and adjusting sourceSets.test.allJava. Still no luck.

What’s even more strange… this works perfectly well in my TestKit tests.

So how exactly does one define the sources for Test?

Thanks

Hi Steve,

test.testClassesDirs should be what you need to set. The test task does not care about .java files, only about .class files. You need to make sure that one of the test.testClassesDirs actually contains .class files.

Cheers,
Stefan

Thanks @Stefan_Wolf

You put me on the right track!