# Cannot expose test class from one subproject to another

**URL:** <https://discuss.gradle.org/t/cannot-expose-test-class-from-one-subproject-to-another/42931>\
**Category:** Help/Discuss\
**Created:** [May 16, 2022, 3:24am UTC](https://discuss.gradle.org/t/cannot-expose-test-class-from-one-subproject-to-another/42931 "2022-05-16T03:24:41Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![juankb1024](https://avatars.discourse-cdn.com/v4/letter/j/ecc23a/32.png) [@juankb1024](https://discuss.gradle.org/u/juankb1024)\
**Post date:** [May 16, 2022, 3:24am UTC](https://discuss.gradle.org/t/cannot-expose-test-class-from-one-subproject-to-another/42931/1 "2022-05-16T03:24:42Z")

</div>

I’ve been trying to do what this answer says to expose some common test classes from subproject “🅰B” to “🅰C” but it fails to compile with NoClassDefFoundError.

> [@Gradle test classes needed in another sub-project](https://discuss.gradle.org/t/gradle-test-classes-needed-in-another-sub-project/13365/2):
>
> Hi, As explained [here](https://docs.gradle.org/current/dsl/org.gradle.api.artifacts.dsl.DependencyHandler.html), a ProjectDependency is a dependency on the default configuration of a particular project. For a java project, the default dependency is an extension of the runtime dependency (as stated in [here](https://docs.gradle.org/current/userguide/java_plugin.html)). In your case, you want to depend on the testRuntime dependency, with something like compile project(':A:B:C', configuration: 'testRuntime') If this doesn’t suit you, you can always create a custom configuration, and depend on it: in :A:B:C project: configurations{ fooConf } t…

I also tried this method but also failed:

> <https://stackoverflow.com/questions/5644011/multi-project-test-dependencies-with-gradle/60138176#60138176>

I’m using gradle 7.2.

How can I consume those classes?

---

<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:** [May 16, 2022, 7:27am UTC](https://discuss.gradle.org/t/cannot-expose-test-class-from-one-subproject-to-another/42931/2 "2022-05-16T07:27:35Z")

</div>

Hi @juankb1024  
can you share a bit more about your project structure ?  
What classes do you want to share between projects ?  
are they some test fixtures that are written in project B, and you want them as well to write some of your tests in project C, or ?

eventually you’ll want (in project C) something like (snippet in groovy)

```gradle
dependencies { testImplementation project(":B") } 

```

to have classes on the _default_ configuration of project B available to the classpath used to compile tests of project C. But the exact syntax will depend on whether those classes are bundled in the default configuration of project B or not, hence the question about the setup of projects B and C
