# testImplementation doesn't obtain src/test/java output

**URL:** <https://discuss.gradle.org/t/testimplementation-doesnt-obtain-src-test-java-output/34544>\
**Category:** Help/Discuss\
**Created:** [January 15, 2020, 8:34pm UTC](https://discuss.gradle.org/t/testimplementation-doesnt-obtain-src-test-java-output/34544 "2020-01-15T20:34:39Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![blakecmartin](https://avatars.discourse-cdn.com/v4/letter/b/91b2a8/32.png) [@blakecmartin](https://discuss.gradle.org/u/blakecmartin)\
**Post date:** [January 15, 2020, 8:34pm UTC](https://discuss.gradle.org/t/testimplementation-doesnt-obtain-src-test-java-output/34544/1 "2020-01-15T20:34:39Z")

</div>

I have a very large multi-module project where module A’s test code depends on module B’s test code.

- A/src/test/java
- B/src/test/java \<== requires classes from A/src/test/java

In the past we’ve created a “test artifact” jar as shown here: [How do i declare a dependency on a module's test code?](https://discuss.gradle.org/t/how-do-i-declare-a-dependency-on-a-modules-test-code/7172/7)

This works: testCompile project (path: ‘:A’, configuration: ‘testArtifacts’)  
This fails: testImplementation project (path: ‘:A’, configuration: ‘testArtifacts’)

I don’t want to completely restructure the project using the new “fixtures”. However, I’d like to migrate to the api/implementation configurations instead of using compile/testCompile for managing dependencies.

What is the preferred way to include a module’s test classes as a dependency for another module?

---

<div class="post-metadata">

**Author:** ![jendrik](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/jendrik/32/7964_2.png) [@jendrik](https://discuss.gradle.org/u/jendrik)\
**Post date:** [January 24, 2020, 8:08am UTC](https://discuss.gradle.org/t/testimplementation-doesnt-obtain-src-test-java-output/34544/2 "2020-01-24T08:08:21Z")

</div>

Hi @blakecmartin,

You can do this by declaring your tests as feature variant:

```gradle
subprojects {
    plugins.withType(JavaLibraryPlugin) {
        java {
            registerFeature('test') { usingSourceSet(sourceSets.test) }
        }
    }
}

```

And then declare a dependency on them like this:

```gradle
    dependencies {
        testImplementation(project(":myOtherProject")) {
           capabilities { requireCapability("project-group:myOtherProject-test") }
        }
    }

```

You could also write a helper method so you get something similar to `testFixtures(...)` when declaring dependencies:

```gradle
def tests(Project project) {
    dependencies.create(project) {
        capabilities { requireCapability("$project.group:$project.name-test") }
    }
}

```

And then you can do:

```gradle
dependencies {
    testImplementation(tests(project(":myOtherProject")))
}

```

More details about feature variants:

- [https://docs.gradle.org/6.0.1/userguide/feature\_variants.html](https://docs.gradle.org/6.0.1/userguide/feature_variants.html)
- [https://blog.gradle.org/optional-dependencies](https://blog.gradle.org/optional-dependencies)

(Test fixtures basically use the same mechanism in the background)

---

<div class="post-metadata">

**Author:** ![jonathan-munoz](https://avatars.discourse-cdn.com/v4/letter/j/a88e4f/32.png) [@jonathan-munoz](https://discuss.gradle.org/u/jonathan-munoz)\
**Post date:** [June 19, 2020, 12:31am UTC](https://discuss.gradle.org/t/testimplementation-doesnt-obtain-src-test-java-output/34544/3 "2020-06-19T00:31:36Z")

</div>

I tried this solution, it didn’t work for me. I have a large android app, that contains many modules, I have the same exact issue as described. the project has no project group or groupid, if I try this solution gradle throws an error saying that the format is groupid:artificat:version, how could I solve this?

Thanks in advance
