Does anyone know of a good way to find out which m...
# community-support
k
Does anyone know of a good way to find out which module's test task (and ideally test) timed out if you kill off a gradle run in CI? We have a flaky unit test that causes a timeout (normal 15min run turns into 45+ minutes which we have a watchdog for that will kill off gradle). Found a few threads with folks hitting a similar problem years ago: https://discuss.gradle.org/t/how-do-i-configure-timeout-for-tests-run-using-the-test-task/5417 https://discuss.gradle.org/t/timeouts-in-junit-tests/318 https://github.com/gradle/gradle/issues/1096 But no real solution 😞 This looked like a clever way to do it via bytecode rewriting: https://github.com/tableau/gradle-test-timeout but it's been deprecated/abandoned. Hmm...maybe this: https://github.com/gradle/gradle/pull/6643
v
Besides the task level timeout, you could configure the test logging to log to the build log which task is currently executed or use some test listener to do custom logging.
k
What's a "test listener"? There's a hook for when individual tests are started/completed? 😮 oh..TIL..something new in gradle 8.7: https://docs.gradle.org/current/javadoc/org/gradle/api/tasks/testing/TestListener.html That's pretty cool...thx for the pointer 🙂 BTW, we found out that 8.8RC1 is 10-15min slower than 8.7 for full builds...that was the actual cause of the build timeout. Still digging at why...
v
👍 1
Same as with https://docs.gradle.org/current/dsl/org.gradle.api.tasks.testing.logging.TestLogging.html#org.gradle.api.tasks.testing.logging.TestLogging where you can just configure the granularity / events if that is enough for you without a custom listener
k
Surprised standard logging doesn't seem to include duration but the TestListener makes that easy to do 🙂
👌 1
v
Remember to use
nanoTime
, not
currentTimeMillis
which is not really suitable to measure durations within the same JVM
👍 1
thank you 1