Hello, I'm currently trying to set up TestBalloon ...
# testballoon
k
Hello, I'm currently trying to set up TestBalloon in my JVM project, but the test task fails because with
Execution failed for task 'convreloc:test'.
There are test sources present and no filters are applied, but the test task did not discover any tests to execute. This is likely due to a misconfiguration. Please check your test configuration. If this is not a misconfiguration, this error can be disabled by setting the 'failOnNoDiscoveredTests' property to false.
I'll post more about my setup in replies.
My project is structured like this:
Copy code
|- build-logic (the "common" plugin)
|- conv/reloc
|  |- src/main/kotlin/.../RelocationSourcePattern.kt
|  |- src/test/kotlin/RelocationSourcePatternTest.kt
|  \- build.gradle.kts
|- build.gradle.kts (just has kotlin and serialization plugins)
\- settings.gradle.kts
settings.gradle.kts
has standard setup with
Copy code
pluginManagement {
    repositories {
        mavenCentral()
        gradlePluginPortal()
    }
}

plugins {
    id("org.gradle.toolchains.foojay-resolver-convention") version "1.0.0"
}

includeBuild("build-logic")
include(
    "conv", "conv:reloc",
)
conv/reloc/build.gradle.kts
has
Copy code
plugins {
    `kotlin-dsl`
    `maven-publish`
    kotlin("jvm") // 2.4.10
    kotlin("plugin.serialization") // 2.4.10
    id("common")
    alias(libs.plugins.kotlin.testballoon) // 1.0.1-K2.4.0
}

dependencies {
    api(project(":conv"))

    testImplementation(libs.kotlin.testballoon) // de.infix.testBalloon:testBalloon-framework-core:1.0.1-K2.4.0
    testImplementation(libs.kotlin.testballoon.assertions) // de.infix.testBalloon:testBalloon-integration-kotest-assertions:1.0.1-K2.4.0
}
RelocateSourcePatternTest
has
Copy code
val RelocateSourcePatternTests by testSuite {
    val validGroups = buildMap {
        this["org/(example)/package"] = listOf(0..4, 2..2)
        this["org/(example/package)"] = listOf(0..4, 2..4)
        this["org/((example)/package)"] = listOf(0..4, 2..2, 2..4)
        this["org/exa(mple/pack)age"] = listOf(0..6, 3..5)
    }

    for ((pattern, groups) in validGroups) test("check groups for '$pattern'") {
        parse(pattern).groups shouldContainExactly groups
    }
}
o
I don't see any obvious problem with that configuration. Let's diagnose! Could you please put the following block into `conv/reloc/build.gradle.kts`:
Copy code
testBalloon {
    debugLevel = DebugLevel.DISCOVERY
}
and then • post the output of
./gradlew :conv:reloc:testBalloonDiagnostics
, and • post the output of
./gradlew :conv:reloc:test --warn
?
k
Yep! The first one is
Copy code
Plugin de.infix.testBalloon: [DEBUG] compiler plugin is not applicable ('main' is not a test source set).

> Task :conv:reloc:testBalloonDiagnostics FAILED

--- BEGIN TestBalloon diagnostics for :conv:reloc ---------------------------------

Project path: :conv:reloc
Gradle version: 9.6.1

Build script plugins block:
  plugins {
      `kotlin-dsl`
      `maven-publish`
      kotlin("jvm")
      kotlin("plugin.serialization")
      id("common")
      alias(libs.plugins.kotlin.testballoon)
  }

Gradle plugins (excerpt, versions from catalog(s) [libs]):
WARNING: Problem configuring task step in 'testBalloonDiagnostics': java.lang.IndexOutOfBoundsException: Index: 1, Size: 1
java.lang.IndexOutOfBoundsException: Index: 1, Size: 1
        at java.base/java.util.Collections$SingletonList.get(Collections.java:5179)
        at de.infix.testBalloon.gradlePlugin.shared.ConfigureWithTestBalloonKt$configureDiagnosticsTask$1.execute$lambda$5(configureWithTestBalloon.kt:469)
        at de.infix.testBalloon.gradlePlugin.shared.ConfigureWithTestBalloonKt$configureDiagnosticsTask$1.execute$safeProvider$lambda$0(configureWithTestBalloon.kt:418)
        at org.gradle.api.internal.provider.DefaultProvider.calculateOwnValue(DefaultProvider.java:73)
        at org.gradle.api.internal.provider.AbstractMinimalProvider.calculateOwnPresentValue(AbstractMinimalProvider.java:80)
        at org.gradle.api.internal.provider.AbstractMinimalProvider.get(AbstractMinimalProvider.java:100)
        at de.infix.testBalloon.gradlePlugin.shared.ConfigureWithTestBalloonKt$configureDiagnosticsTask$1$3.execute(configureWithTestBalloon.kt:493)
        at de.infix.testBalloon.gradlePlugin.shared.ConfigureWithTestBalloonKt$configureDiagnosticsTask$1$3.execute(configureWithTestBalloon.kt:490)
        at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:850)
        // ... Gradle internals, very long

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':conv:reloc:testBalloonDiagnostics' (registered by plugin 'de.infix.testBalloon').
> Cannot query the value of this provider because it has no value available.
And the second:
Copy code
Plugin de.infix.testBalloon: [DEBUG] compiler plugin is not applicable ('main' is not a test source set).
Plugin de.infix.testBalloon: [DEBUG] adding JUnit Platform launcher to configuration ':conv:reloc:testRuntimeOnly'.
w: Plugin de.infix.testBalloon: [DEBUG] version 1.0.1-K2.4.0 is processing module <fletching-table-boogaloo.conv:fletching-table.conv.reloc_test>.
w: Plugin de.infix.testBalloon: [DEBUG] JUnit 4 is not on the classpath.
w: file:///home/kikugie/IdeaProjects/fletching-table-boogaloo/conv/reloc/src/test/kotlin/RelocateSourcePatternTest.kt:1:1 Plugin de.infix.testBalloon: [DEBUG] Analyzing source file.
w: file:///home/kikugie/IdeaProjects/fletching-table-boogaloo/conv/reloc/src/test/kotlin/RelocateSourcePatternTest.kt:9:1 Plugin de.infix.testBalloon: [DEBUG] Found top-level test suite property 'RelocateSourcePatternTests'.
w: file:///home/kikugie/.gradle/daemon/9.6.1/de/infix/testBalloon/framework/shared/internal/entryPoint/JvmEntryPoint.kt Plugin de.infix.testBalloon: [DEBUG] Analyzing source file.

[Incubating] Problems report is available at: file:///home/kikugie/IdeaProjects/fletching-table-boogaloo/build/reports/problems/problems-report.html

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':conv:reloc:test'.
> There are test sources present and no filters are applied, but the test task did not discover any tests to execute. This is likely due to a misconfiguration. Please check your test configuration. If this is not a misconfiguration, this error can be disabled by setting the 'failOnNoDiscoveredTests' property to false.
o
OK, the first one is a deficiency of the
testBalloonDiagnostics
task. It does not affect normal processing, just the diagnostics. Could it be that you don't use a version catalog? The second one looks correct except for the final error: TestBalloon correctly discovers your test suite and generates the necessary startup code. However, it is not invoked by JUnit Platform. Could it be that there is some JUnit (Platform) configuration present either in the build script or in one of your Gradle convention plugins?
And because we recently had a case where the IDE interfered in strange ways: Could you try running
./gradlew :conv:reloc:test
from the command line if you had used the IDE before?
k
I don't configure JUnit anywhere - the convention plugin only does the following: • Configure project version and base.archivesName from properties. • Add maven central repository. • Configure Java to compile to version 17 with sources. • Register maven publication. I tried adding
Copy code
testImplementation("junit:junit:4.13.2")
testImplementation("org.junit.platform:junit-platform-launcher:1.14.4")
which now prints
w: Plugin de.infix.testBalloon: [DEBUG] JUnit 4 is on the classpath, but the TestBalloon JUnit 4 runner is not.
when running
./gradlew :conv:reloc:test --warn
, with the rest being identical, as well as the diagnostics task. Also, both these and previous tests were done from CLI.
o
Everything looks totally reasonable. TestBalloon supports JUnit 4 for Android only, which is why you're seeing
the TestBalloon JUnit 4 runner is not
[on the classpath] on the "regular" JVM. TestBalloon also auto-configures the JUnit Platform launcher, so adding it explicitly doesn't change anything. Could you share a small, self-contained reproducer (public or via DM). I'd look into this as soon as I can, but it will probably take a day until I get to this.
k
When making the reproducer I found out that
kotlin-dsl
plugin causes the issue.
o
Oh, that's interesting! The
kotlin-dsl
plugin is typically used in convention plugins (and even there it causes problems). In a build script, it is not necessary.
k
It's also used to develop precompiled Gradle plugins in Kotlin, which is what this going to be.
o
Ah, OK. I'll look into this and I'll also try to find some information about the problems with
kotlin-dsl
. I have abandoned it long ago.
k
Thanks, for the purpose of the plugin, applying
implementation(gradleKotlinDsl())
fixes tests, and adds extensions I use to the classpath.
o
Cool. kodee happy Thanks for investigating!