Dump stack trace for tests

Is there a way to dump stack trace of VM in certain tests? My tests only fail when ‘all’ run at once so I need to run them all and dump 1 test’s stack trace after it starts 20 seconds in or so to see what is going on. Is there a way to do this?

or just auto stack dump any test that takes over 20 seconds would be sick!!! does that exist?


The Gradle build uses something for its integration tests: https://github.com/gradle/gradle/blob/903c5f2cee88c9768077d46025eaafdf65862fc8/buildSrc/subprojects/integration-testing/src/main/kotlin/org/gradle/gradlebuild/test/integrationtests/IntegrationTest.kt#L39-L76

So if an integration test task takes more than a certain amount of time, the stack traces are printed to the console log. This allows us to analyze hanging tests.