This message was deleted.
# community-support
s
This message was deleted.
c
Gradle expects tests to be in the source set location (by default, src/test/<lang>. Did you reconfigure the source set when moving the files?
e
@Chris Lee that part hasn't changed.
my issue was that my folder names were containing
.
s like
my.package
, and I moved them to
my/package
folder structure
c
Directory listing would help.
e
In what sense? I had
src/test/kotlin/my.package/Test.kt
and now its
src/test/kotlin/my/package/Test.kt
c
And how are you running the tests? ,/gradlew test?
e
Yes
c
how did this ever work:
src/test/kotlin/my.package/Test.kt
- it isn’t a valid package name. What is the package declaration in
Test.kt
?
and: what is the full output from
./gradlew test
; it will show the tasks (and their dependencies), whether it compiled any files or not, etc.
e
in
Test.kt
it's:
Copy code
package my.package

class Test {
    @Test
    fun foo() {
        // my test logic
    }
}
so actually the class package name was matching the pattern of
my.package
, it's just the storing directory which was named incorrectly
Copy code
Execution failed for task ':my:unit-test'.
> No tests found for given includes: [my.package.Test.get status of non-existing job throws error](--tests filter)

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
> Get more help at <https://help.gradle.org>.
Deprecated Gradle features were used in this build, making it incompatible with Gradle 9.0.
You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.
For more on this, please refer to <https://docs.gradle.org/8.2.1/userguide/command_line_interface.html#sec:command_line_warnings> in the Gradle documentation.
BUILD FAILED in 19s
21 actionable tasks: 21 executed
c
the full output. please - useful stuff preceding the error.
do you have any test include filters in the build script?
e
Copy code
> Task :my:compileKotlin
> Task :my:compileJava NO-SOURCE
> Task :my:classes
> Task :my:compileTestKotlin
> Task :my:compileTestJava NO-SOURCE
> Task :my:testClasses
> Task :my:unit-test
> Task :my:unit-test FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':my:unit-test'.
> No tests found for given includes: [my.package.Test.get status of non-existing job throws error](--tests filter)
* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
> Get more help at <https://help.gradle.org>.
Deprecated Gradle features were used in this build, making it incompatible with Gradle 9.0.
You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.
For more on this, please refer to <https://docs.gradle.org/8.2.1/userguide/command_line_interface.html#sec:command_line_warnings> in the Gradle documentation.
BUILD FAILED in 19s
21 actionable tasks: 21 executed
c
> Task :my:compileTestJava NO-SOURCE
check where the source sets are configured for and the layout of
src/test/java
e
there's no Java at all
this project is full Kotlin
c
ah cool. ok, it looks like it compiled the test classes. let’s check the test setup in your build script.
this is unusual;
Copy code
> No tests found for given includes: [my.package.Test.get status of non-existing job throws error](--tests filter)
e
so this is the output of attempting to run that unit test directly
c
yep. in the build script are you configuring the
test
task?
e
yes
it's a multi-module project, here's the relevant part:
Copy code
subprojects {
    afterEvaluate {
        tasks.create<Test>("unit-test") {
            group = "verification"

            useJUnitPlatform {
                excludeTags("integrationtest", "systemtest")
            }
        }

        tasks.withType<Test> {
            useJUnitPlatform()
            testLogging {
                events("passed", "skipped", "failed")
            }
        }    
    }
}
c
ok. thx. if you run just
./gradlew unit-test
do the tests run?
btw,
subprojects
and
afterEvaluate
are anti-patterns, they cause all kinds of challenges. Not this one, though. Something to consider cleaning up.
e
nope
they don't run
what to use instead of subprojects and afterEvaluate?
c
yea. this task:
Copy code
tasks.create<Test>("unit-test") {
            group = "verification"

            useJUnitPlatform {
                excludeTags("integrationtest", "systemtest")
            }
        }
is a new Test task - is it somewhere wired to a source set? Otherwise it won’t know what to execute. If your unit tests are in
src/test/kotlin
then
./gradlew test
will run them.
This shows how to create a new source set and test task for it.
e
ok, it's getting more weird. I thought it's just the projects gradle internal something that messed up. I pulled down my project to a brand new repo, and the same error happens.
c
if you are trying to run the `unit-test`` task it doesn’t look like it could ever have worked, its not referencing any source code (as far as I can see).
Did your code get inadvertently moved between source sets? What does a diff against a baseline show for that?
e
if I run
unit-test
from the root project several tests are running, but not the one I have hproblem with.
c
is there more build script code that creates a sourceset and links it to that
unit-test
task? There has to be, somewhere, otherwise its an empty task.
e
no that's the only part
c
then it has no reference to your source, hence the error. Check your package renaming change against a baseline to confirm that things didn’t get moved between folders, or perhaps revert it back to confirm that this actually worked (from the task definition and the mis-named directories it doesn’t seem like it).
e
to add more info, everything works for other subprojects
there is only one which has this issue
figured it out
I'm so sorry.
in the subproject gradle file there was a tag include/exclude condition
it wouldn't work before renaming
🤦
c
all good, glad its working now!
e
thanks for the help tho!
👍 1