# Test task and NO\_SOURCE

**URL:** <https://discuss.gradle.org/t/test-task-and-no-source/40247>\
**Category:** Help/Discuss\
**Created:** [June 17, 2021, 1:20pm UTC](https://discuss.gradle.org/t/test-task-and-no-source/40247 "2021-06-17T13:20:23Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Steve\_Ebersole](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/steve_ebersole/32/9763_2.png) [@Steve\_Ebersole](https://discuss.gradle.org/u/Steve_Ebersole)\
**Post date:** [June 17, 2021, 1:20pm UTC](https://discuss.gradle.org/t/test-task-and-no-source/40247/1 "2021-06-17T13:20:23Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Stefan\_Wolf](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/stefan_wolf/32/5519_2.png) [@Stefan\_Wolf](https://discuss.gradle.org/u/Stefan_Wolf)\
**Post date:** [June 18, 2021, 9:01am UTC](https://discuss.gradle.org/t/test-task-and-no-source/40247/2 "2021-06-18T09:01:15Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Steve\_Ebersole](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/steve_ebersole/32/9763_2.png) [@Steve\_Ebersole](https://discuss.gradle.org/u/Steve_Ebersole)\
**Post date:** [June 18, 2021, 2:55pm UTC](https://discuss.gradle.org/t/test-task-and-no-source/40247/3 "2021-06-18T14:55:58Z")

</div>

Thanks @Stefan_Wolf

You put me on the right track!
