Gradle test report : Standard output per test method

Hi all,

in gradle test report I see that most deep element is test class and I can see standard output from execution of test class, but is there is a possibility to make per test method standard output available somehow ?

Regards,

Grzesiek

I believe what you are looking for is TestLoggingContainer#minGranularity with value 3 (which corresponds to test method).

test {
    testLogging {
        minGranularity = 3
    }
}

Hmm that does not help, in report I cannot enter single test method, they are all group by test class. It seems like this option is related to logging events, not report generation.

Or I use it wrong, here is my build.gradle

test {
    useJUnit()
    testLogging {
        minGranularity = 3
        showExceptions = true
    }
}

also I discover that all NullPointerExeption, which are reported as “Error” in maven, are reported as “Failure” in gradle, this is desired behavior ?

Regards,

Grzesiek

Hmm that does not help, in report I cannot enter single test method, they are all group by test class. It seems like this option is related to logging events, not report generation.

I thought that’s what you are asking about. Can you please elaborate by example on what you mean by report generation? Are you asking to see a report that is rendered by test methods on the the top-level of the report dashboard? If that’s the case, it’s not configurable.

also I discover that all NullPointerExeption, which are reported as “Error” in maven, are reported as “Failure” in gradle, this is desired behavior ?

It’s probably the same - the test failed for some reason. There is not error state in Gradle. Keep in mind that Gradle does not try to align with Maven terminology on this front.

One more comment about your code. Assuming that you apply the Java plugin, applying the method test.useJUnit() is not required. JUnit is the default test framework and is already pre-configured for you by the Java plugin.

is there any new on that? if i look in the junit xml/html reports the only thing i see is per class log statements. is it possible to get per method logs?

1 Like

Did you find a solution to get the logstatements in the report per methods?

Yes, I have used https://github.com/radarsh/gradle-test-logger-plugin , works like a charm