We upgraded our build setup from 8.12 to 9.1 and I...
# community-support
e
We upgraded our build setup from 8.12 to 9.1 and I just discovered that our unit test handling doesn't work properly any more. We have a number of sub projects, and we are using
ignoreFailures=true
to keep running unit tests, even after a failure in one of the sub projects.
We have a failure checker that keeps a counter & check for unit test failures.
Copy code
reporting {
    reports {
        val failureCheck = gradle.sharedServices.registerIfAbsent("testFailureCheck", TestFailureCheck::class) {}
        @Suppress("UnstableApiUsage")
        val testAggregateTestReport by creating(AggregateTestReport::class) {
            testSuiteName = "unit-tests"
            reportTask.configure {
                doLast {
                    // print a short summary and fail build if any test failed
                    failureCheck.get().execute(destinationDirectory.get().asFile)
                }
            }
            test.configure {
                dependsOn(reportTask)
            }
        }
That's the crucial part - with gradle 8.12, that
doLast
got called always, and then our check got executed.
With 9.1, the code given to
doLast
isn't invoked any more. (I think 8.13 slightly change the overall handling, as it introduced that
testSuiteName
property for the aggregate code.
Any idea anyone how to fix this? Resolved: the problem is this line:
testSuiteName = "unit-tests"
Previously, the test report used an enum, and now asked for a string, so I just wrote down "unit-tests". Which is wrong - this needs to refer an existing test suite, and in our case, that would be the default ("test"). With that change, things work as expected.
t
is there any advantage in using your aggregate service failure check +
ignoreFailures
over just passing `--continue`on the commandline ? we just use
--continue
and that seems to match what you are doing...
👆 1
v
Also, if you want to aggregate test reports, you might consider using the
test-report-aggregation
plugin
e
@TheGoesen
--continue
affects any failing task. And it requires users to actually put it on the command line.
@Vampire We are using that plugin
👌 1
t
well if its really useful to you... to debug your issue check the output of gradle. the doLast block really should be executed if the reportTask is executed. I would guess that either the reportTask will not be part of the task graph or it is UP-TO-DATE
or FROM-CACHE
v
Can you maybe knit an MCVE that shows your exact situation that works with 8 but fails with 9? That might enable someone to see the problem maybe.
e
I feared you would ask for that. No time for that right now, unfortunately. I had hoped someone has a good idea that would help.
t
I am not very familiar with `test-report-aggregation`but i am not sure what you are doing is correct in the first place... So according to your code
test
depends on the aggregation-report, but the job of the aggregation would be to aggregate the report of exactly that test?
e
Fix was ... super easy. See my update to the initial posting 🫠
👌 1