Slackbot
11/18/2022, 9:24 AMVampire
11/18/2022, 10:34 AMtestFixtures(...)
helper that does it for you.Javi
11/18/2022, 12:27 PMVampire
11/18/2022, 1:09 PMimplementation(testFixtures(project("a:b:c"))
. It basically just sets the proper attributes on the dependency which you could also do manually if you prefer.Javi
11/26/2022, 5:52 PMdependencies {
"integrationTestImplementation"(testFixtures(project))
}
Vampire
11/26/2022, 6:50 PMJavi
11/26/2022, 6:52 PMVampire
11/26/2022, 6:53 PMVampire
11/26/2022, 6:54 PMintegrationTest
Vampire
11/26/2022, 6:55 PMtesting {
suites {
val integrationTest by registering(JvmTestSuite::class) {
dependencies {
...
implementation(testFixtures(project()))
}
}
}
}
Javi
11/26/2022, 6:58 PMsourceSets.named("functionalTest") { set -> set.dependencies { configureTestDependencies() } }
private fun KotlinDependencyHandler.configureTestDependencies() {
implementation(testFixtures(project))
...
}
I have to investigate about test suites yet and how they work on all kind of Kotlin projects (probably they don't work on KMP right? If so, I don't want to mix yet different concepts)Vampire
11/26/2022, 6:59 PMVampire
11/26/2022, 6:59 PMJavi
11/26/2022, 6:59 PMVampire
11/26/2022, 6:59 PMproject.dependencies.testFixtures(...)
Javi
11/26/2022, 7:00 PMJavi
11/26/2022, 7:00 PMpublic fun KotlinDependencyHandler.testFixtures(notation: Any): Dependency =
project.dependencies.testFixtures(notation)
Vampire
11/26/2022, 7:00 PMJavi
11/26/2022, 7:00 PMJavi
11/26/2022, 7:01 PMVampire
11/26/2022, 7:01 PMtestFixtures(...)
helper is just setting the attributes for youVampire
11/26/2022, 7:01 PMtestFixtures(...)
method from project.dependencies
Javi
11/26/2022, 7:02 PMVampire
11/26/2022, 7:03 PMVampire
11/26/2022, 7:03 PMJavi
11/26/2022, 7:04 PMJavi
11/26/2022, 7:06 PM// KMP project
println("Sources: ${the<SourceSetContainer>().size}") // Sources: 0
println("Sources: ${the<KotlinMultiplatformExtension>().sourceSets.size}") // Sources: 83
// Kotlin JVM project
println("Sources: ${the<SourceSetContainer>().size}") // Sources: 2
println("Sources: ${the<KotlinJvmProjectExtension>().sourceSets.size}") // Sources: 2
val topLevel: SourceSetContainer = sourceSets
val javaContainer: SourceSetContainer = java.sourceSets
val kotlinContainer: NamedDomainObjectContainer<KotlinSourceSet> = kotlin.sourceSets
Javi
11/26/2022, 7:06 PMJavi
11/26/2022, 8:34 PMHowever we cannot choose between the following variants of project :hubdle-gradle-plugin:
- runtimeElements
- testPluginClasspath
Looks like I have to fix my custom configuration used for Gradle testkit testsJavi
11/26/2022, 9:41 PMGRADLE_PLUGIN_API_VERSION_ATTRIBUTE
as it is calculated automatically,
which I had to add to my custom testPluginClasspath
configuration some months ago.
Now I am on Gradle 7.6 and on Kotlin 1.7.20. Should it be safe to delete that attribute?Javi
11/26/2022, 9:42 PMconfigurations.creating {
val kotlinVersion = Version.safe(project.getKotlinPluginVersion()).getOrNull()
if (kotlinVersion != null && kotlinVersion >= Version("1.7.0"))
attributes { attributes ->
attributes.attribute(USAGE_ATTRIBUTE, objects.named(JAVA_RUNTIME))
attributes.attribute(CATEGORY_ATTRIBUTE, objects.named(LIBRARY))
attributes.attribute(
GRADLE_PLUGIN_API_VERSION_ATTRIBUTE,
objects.named("7.0")
)
}
}
Javi
11/26/2022, 9:53 PM