# How do I include test sources along side test jar?

**URL:** <https://discuss.gradle.org/t/how-do-i-include-test-sources-along-side-test-jar/12380>\
**Category:** Help/Discuss\
**Created:** [October 23, 2015, 2:42am UTC](https://discuss.gradle.org/t/how-do-i-include-test-sources-along-side-test-jar/12380 "2015-10-23T02:42:33Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![andrew\_sumner1](https://avatars.discourse-cdn.com/v4/letter/a/779978/32.png) [@andrew\_sumner1](https://discuss.gradle.org/u/andrew_sumner1)\
**Post date:** [October 23, 2015, 2:42am UTC](https://discuss.gradle.org/t/how-do-i-include-test-sources-along-side-test-jar/12380/1 "2015-10-23T02:42:33Z")

</div>

I’m outputting the test jar using:

```
task testJar(type: Jar) {
 	classifier = 'tests'
	from sourceSets.test.output
}

```

and had a guess at test sources:

```
task testSourcesJar(type: Jar, dependsOn: classes) {
    classifier = 'testSources'
    from sourceSets.test.allSource
}

```

But when I attempt to get the dependencies in another project I can get the test classes but not the source code

```
testCompile 'my.other:project:1.7:tests'
```

---

<div class="post-metadata">

**Author:** ![Francois\_Guillot](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/francois_guillot/32/8566_2.png) [@Francois\_Guillot](https://discuss.gradle.org/u/Francois_Guillot)\
**Post date:** [October 23, 2015, 6:36am UTC](https://discuss.gradle.org/t/how-do-i-include-test-sources-along-side-test-jar/12380/2 "2015-10-23T06:36:50Z")

</div>

In your testCompile dependency declaration, you’re using the tests classifier, so you’re retrieving your testJar jar, which only contains the test output.  
You should also add a dependency on your testSource jar:  
testCompile ‘my.other:project:1.7:testSources’

Or simply merge your Jars  
task testJar(type: Jar) {  
classifier = 'tests’  
from sourceSets.test.output+sourceSets.test.allSource  
}
