Slackbot
10/25/2022, 10:39 PMJohn Bellini
10/26/2022, 12:03 AMtest.maxParallelForks = System.getProperty("maxTestParallelForks")?.toInt() ?: ((Runtime.getRuntime().availableProcessors() / 2).takeIf { it > 0 } ?: 1)Vampire
10/26/2022, 7:15 AMDaniel Svensson
10/26/2022, 7:25 AMVampire
10/26/2022, 7:31 AMDaniel Svensson
10/26/2022, 7:32 AMsystemProperty("junit.jupiter.execution.parallel.enabled", "true")
systemProperty("junit.jupiter.execution.parallel.mode.default", "same_thread")
systemProperty("junit.jupiter.execution.parallel.mode.classes.default", "concurrent")
for all tests, and org.gradle.parallel=trueDaniel Svensson
10/26/2022, 7:33 AMDaniel Svensson
10/26/2022, 7:35 AMVampire
10/26/2022, 7:35 AMDaniel Svensson
10/26/2022, 7:36 AMVampire
10/26/2022, 7:37 AMDaniel Svensson
10/26/2022, 7:37 AMDaniel Svensson
10/26/2022, 7:38 AMVampire
10/26/2022, 7:38 AMDaniel Svensson
10/26/2022, 8:19 AMCristianGM
10/27/2022, 7:08 AMDaniel Svensson
11/01/2022, 5:33 PMOne option would be to define an "aggregator" Gradle subproject that defines a Gradletask and contains aTestclass that runs all tests. That subproject would then have dependencies on the test source sets of all other subprojects.@Suite
Sounds like something that could work even if it's not entirely clear how I would do that. So I guess instead of just running
./gradlew test in CI, you would then run ./gradlew :ci:test for example which would fork once and let junit engine schedule the tests across the number of cores available. The @Suite part looks trivial, but it would be cool if it was possible to automatically add all test source sets (with their corresponding testImplementation-deps) dependencies to the hypothetical :ci:test task. Sounds doable, but my gradle-fu is too weak to simply envision it. Any suggestions? Otherwise a hardcoded list of dependencies would be fairly low maintenance in my use case.Daniel Svensson
11/01/2022, 5:43 PMVampire
11/01/2022, 7:16 PMjava-test-fixtures plugin does it, just not with an extra source set.
Or you actually use the java-test-fixtures plugin and move all your tests into that source set, but I think that is the less clean solution.Daniel Svensson
11/01/2022, 7:35 PMtest*-dependencies in the whole project to that :ci:test project?Vampire
11/02/2022, 7:39 AMVampire
11/02/2022, 7:40 AMDaniel Svensson
11/02/2022, 7:49 AMDaniel Svensson
11/07/2022, 4:43 PMtestRuntimeOnly(projects.some.subprojectFoo) but then I can't seem to declare a specific configuration, and testRuntimeOnly(project(":some:subprojectFoo", configuration = "exportedTests")) leads to Project with path ':some:subprojectFoo' could not be found in project ':some:thetests'. what would be the correct way to refer to the other projects tests?
Adding the jars to the exportedTests like:
val testJar = register("testJar", Jar::class.java) {
archiveClassifier.set("test")
from(sourceSets.test.map { it.output })
}
artifacts {
add("exportedTests", testJar)
}Vampire
11/07/2022, 4:58 PMtestImplementation(projects.some.subprojectFoo) { targetConfiguration = "exportedTests" }Daniel Svensson
11/07/2022, 7:27 PMDaniel Svensson
11/07/2022, 7:29 PMtestRuntimeOnly(projects.foo.somesubproject) { targetConfiguration = "exportedTests" } strategy for referencing the other artifacts had the same result as project("...", configuration = "...") ... is that because they are sibling directories or that doesn't matter?Daniel Svensson
11/07/2022, 7:31 PMval exportedTests by configurations.creating {
isCanBeConsumed = true
isCanBeResolved = false
// If you want this configuration to share the same dependencies, otherwise omit this line
extendsFrom(configurations["testImplementation"], configurations["testRuntimeOnly"])
}Daniel Svensson
11/07/2022, 7:38 PMDaniel Svensson
11/07/2022, 7:54 PMtestRuntimeOnly(projects.foo.subprojectA.tests) or .integrationTests and poff the @Suite tagged test class would know of all the tests and all their deps etc without any need of creating jars or whatnot.Vampire
11/08/2022, 9:46 AMSo src/test/kotlin/* can be part of two feature variants and still only be compiled once?By default it is not part of a feature variant, otherwise you could simply use that one. But yes, you can have multiple feature variants for the same code and for example just have different dependencies, or you can have different feature variants that provide different code, many possibilities.
Using theOf course, it is just the project accessors syntax, but effectively the same. Didn't realize there was a problem with the latter.strategy for referencing the other artifacts had the same result astestRuntimeOnly(projects.foo.somesubproject) { targetConfiguration = "exportedTests" }project("...", configuration = "...")
is that because they are sibling directories or that doesn't matter?That shouldn't matter, the other project should be found. Hard to say what is wrong there without an MCVE.
Is there any issue with how I register the exportedTests?Seems fine from a first look. MCVE might help.
Does the names have any significance here?No, they are freely choosable
Are those two magically related?No, just what is configured.
It's first after the use of instrumentedClasspath that there comes a declaration in the documentation, is that wrong, or is instrumentedClasspath actually automatically declared by the former steps?No, no automatism there. It just first shows how to declare the dpendency, but in the build script you actually should have the configuration created first.
without any need of creating jars or whatnot.That's why I said you should use a feature variant. That makes the jar task declaring and so on for you implicitly.
Daniel Svensson
11/08/2022, 9:59 AMDaniel Svensson
11/10/2022, 12:24 PMregisterFeature("allTheTests") { usingSourceSet(sourceSets["test"]) } no allTheTests* will be registered. If I change to sourceSets["main"] I will get allTheTestsRuntimeOnly and friends - but wrong sourceSet. Kind of tricky to google on, nobody does things like this.Daniel Svensson
11/10/2022, 1:08 PMDaniel Svensson
11/10/2022, 4:34 PMDaniel Svensson
11/11/2022, 4:01 PMDaniel Svensson
11/11/2022, 4:03 PMVampire
11/11/2022, 4:04 PM