Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 616
Dacav Avatar asked Sep 06 '16 13:09

Dacav


People also ask

How do I get stack trace on my Android?

If it seems like your app has crashed, the first thing you will want to do is examine the stack trace that is associated with this crash. These are logged to a facility known as Logcat, on your device or emulator. You can view those logs using the Logcat tool in Android Studio.

Where are gradle logs stored?

Gradle does not redirect its logs in a separate file in Android Studio. Therefore if you want to view them in a file, you need to build gradle using a command in the terminal and redirect gradle input to a file. This command will redirect all standard output and error messages from gradle build to a file called myLogs.


2 Answers

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).

like image 187
Dacav Avatar answered Oct 04 '22 22:10

Dacav


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
    }
  }
}
like image 36
Александра Головина Avatar answered Oct 04 '22 22:10

Александра Головина