Unit Testing Build freezes/hangs up without specific reason

Hi there!

We are currently experiencing freezes when running Unit Tests via Console using the gradlew test task. The process stops at an unspecific test and just freezes without any output. When changing/commiting code the test at which the process is stopped changes. We are currently using Gradle 3.4.1 and Robolectric 3.1.

This is the “testung” part of our build.gradle:

tasks.withType(Test) {
    maxParallelForks = Runtime.runtime.availableProcessors()
    forkEvery=50
    testLogging {
        events 'skipped', 'failed'
        exceptionFormat 'full'
        afterSuite { desc, result ->
            if (!desc.parent) { // will match the outermost suite
                println "Results: ${result.resultType} (${result.testCount} tests, ${result.successfulTestCount} successes, ${result.failedTestCount} failures, ${result.skippedTestCount} skipped)"
            }
        }
    }
    maxHeapSize '6144m'
    // Forked processes like GradleWorkerMain for tests won't steal focus!
    jvmArgs '-Djava.awt.headless=true'
}

This is our gradle-wrapper.properties file:

distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-3.4.1-bin.zip
org.gradle.daemon=true
org.gradle.parallel=true
android.enableBuildCache=true

This is what our global gradle.properties file says:

org.gradle.parallel=true

You might have some tests in place that cause a deadlock (one waiting on the other one) when run in parallel. I’d try to figure out if you see a pattern for specific tests. Does the test task always get stuck or just sometimes?

We have investigated our tests to this extent, but we couldnt find any possible causes for a dead lock. The test task gets stuck always.

Did you figure out which test might be responsible for hanging? You could use testing logging to write each of the tests to a file to determine which one was started last. I’d also try to run the tests without maxParallelForks to see if that’s happening as well.