Configure test dependends on custom configuration in same project

we configure a separate configuration and we need the test dependencies depends on that custom configuration

configurations {
    customConfiguration { canBeConsumed = true }
}

we tried to specify the test dependencies as:

dependencies {
       testImplementation sourceSets.customConfiguration.output,
                                         sourceSets.customConfiguration.compileClasspath,

}

we could still run the test from intellij, however intellij complains that it couldn’t find references to classes in the customConfiguration

Thanks

What problem are you trying to solve here? Is it just that you want a separate container for dependencies? Will customConfiguration contain compiled sources? Are you trying to share test fixtures? I think how you want to use this configuration speaks to the best way to configure it.

  1. what problem are you trying to solve here?
  • I’m sorry I’m not clear on the problem, essentially, I forgot to mention that we also configure intellij to pick up the the “sources” of customConfiguration as “testSources”
idea {
    module {
        testSourceDirs += sourceSets.customConfiguration.java.srcDirs
        testSourceDirs += sourceSets.customConfiguration.resources.srcDirs
    }
}

so basically, the problem is where intellij couldn’t pick up java sources in customConfiguration, as intellij only understand the dependencies on modules “java sources” and not “java test sources”, so the moment we remove the line “testSourceDirs += sourceSets.customConfiguration.java.srcDirs”, intellij can understand the classes in the customConfiguration.java.srcDirs.

  1. “Is it just that you want a separate container for dependencies? Will customConfiguration contain compiled sources? Are you trying to share test fixtures?”
  • basically, we have some common test utilities, glue code for cucumber tests, etc… and that’s why you need to extract those common “test code” into separate modules customConfiguration.

Thanks for your help.
Cheers