I'm trying to set up <feature variants>, and I wan...
# community-support
a
I'm trying to set up feature variants, and I want to test the features separately. I tried using the JVM test suites plugin, but the tests sources can't see files in the main sources. I would like something like this:
Copy code
val foo by sourceSets.creating {
  // main 'foo' sources
}

val fooTest by sourceSets.creating {
  // tests for the main 'foo' source set
  extendsFrom(foo) // make the foo code visible in the foo tests
}
Are there any examples for extending one custom source set with another? StackOverflow is full of answers that seem hacky and non-idiomatic.
oh wait feature variants
a
I've tried variations of that, but no joy yet
Copy code
testing {
    suites.create<JvmTestSuite>("fooTest") {
        dependencies {
            implementation(project(project.path)) {
                val cap = provider { "${group}:${name}-foo" }
                capabilities { requireCapability(cap) }
            }
        }
    }
}
e
never tried before, but what goes wrong with that?
a
compilation fails because classes from
src/foo
aren't visible in
src/fooTest
e
I'd honestly expect that
Copy code
implementation(project) {
    capabilities { ... }
would set it up right but hmm
public classes missing, or just Kotlin
internal
? IDE or command line build? (I think there's a number of intellij bugs around jvm test suites)
a
I think that all dependencies are resolved correctly, except for
gradleTestKit()
. It's just classes from
src/foo
that are missing.
I see the same failures when running
./gradlew check
as in IntelliJ
the only suspicion I have is that when looking a the
testFixtures()
util function it modifies the dependency to append
-test-fixtures
using internal Gradle functionality. So maybe it's just not possible for a project to depend on a variant of itself without using Gradle internals.
ah I got it working! But it's flaky. Disabling configuration cache and build cache and adding
--run-tasks
helped.
😱 2