'Gradle stack trace on terminal

I'm required to use Gradle for my Java project. I'm running some unit tests with ./gradlew test, but the exception stack trace is witten on a web page which I need to load in a browser.

Why such complication?

Is there a way of getting it on the terminal instead, as I Maven does?



Solution 1:[1]

According to this page the following will do:

test {
    testLogging {
        exceptionFormat = 'full'
    }
}

This is actually working. It's not really showing the whole exception trace, but (even better?) it shows the relevant part of it (that is, the part associated to the code written in the unittest).

Solution 2:[2]

For gradle (kotlin dsl) you could do this:

import org.gradle.api.tasks.testing.logging.TestExceptionFormat

tasks {
  test {
    testLogging {
        events("passed", "skipped", "failed")
        showStackTraces = true
        exceptionFormat = TestExceptionFormat.FULL
    }
  }
}

Solution 3:[3]

Here is what worked for me in the Android project. To module level build.gradle file (such as app/build.gradle), add the following lines:

plugins {
    // ...
}

android {
    // ...
}

tasks.withType(Test) {
    testLogging {
        exceptionFormat = 'full'

        // Optionally do:
        showStackTraces = true
    }
}

dependencies {
    // ...
}

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Dacav
Solution 2 ?????????? ????????
Solution 3 Top-Master