How do I configure logging of per-project test summaries to the console?


(Alan LaMielle) #1

I’m looking for a way to configure per-project test run summary logging to the console. For example, this post (http://forums.gradle.org/gradle/topics/whats_new_in_gradle_1_1_test_logging) shows an example from Gradle 1.1: 4 tests completed, 1 failed, 1 skipped But this version is a bit older. I’d like to have something like that same summary output logged to the console for each project with tests.

I’ve found various suggestions for writing a custom hook to print this info, but it seems like this is something that would be built in. Any ideas?


(Peter Niederwieser) #2

What exactly is the goal? Gradle doesn’t build one project after another, but one task after another, and depending on task dependencies, it will happily jump forth and back between projects. So when do you want to print the summary? The only thing that’s built-in is a test task summary.


(Alan LaMielle) #3

Thanks for your response Peter! At this point I’d be happy with any summary at all. After spending more time searching than I would have liked, I was not able to find a way to enable any sort of summary at all. Printing something after each test task would be 100% better than what I have now!

For a bit more context, I’m in the process of moving from Maven to Gradle and one extremely useful bit of output from our current maven builds is seeing the number of tests that were run for each sub-project as part of the build output. I’m simply looking for some sort of equivalent to that (without having to open the auto-generated HTML or XML reports).

Can you provide a build script sample that will produce this sort of output?


(Peter Niederwieser) #4

Oh I see. You’ll get the per-test-task summary for free, but it won’t persist after the task has finished. I’d prefer it to stay too, but that’s not currently possible. What you can always do is to use the hooks provided by the ‘Test’ task type to print your own summary. For API details, see ‘Test’ in the Gradle Build Language Reference. You might also find related information in the Gradle User Guide and/or the samples in the full Gradle distribution (see ‘samples’ directory).

This only applies to local command line builds. IDEs and CI servers will typically give you a summary anyway.


(Alan LaMielle) #5

Ok, thanks for the info Peter! I will look into adding a custom hook. I started down that path but it really felt like something that should be built in, so I stopped. Seeing that Gradle used to provide the output I wanted was also what made this so frustrating.

Since it used to have this feature (per your post from ~1 year ago that I linked to above), would it be possible to get it added back in a future release? Or was a firm decision previously made that this isn’t something that should be part of the core Gradle distribution? If adding it back may be possible, is there a recommended channel to submit an improvement request?


(Peter Niederwieser) #6

I don’t think it ever had that feature. The summary always went away at the end. Probably the decision was made because it matches the general philosophy of Gradle to have minimal default output if all goes well. It shouldn’t be hard to make this configurable, though. Perhaps you’d be interested in contributing? That’s the fastest way to get this in.


(Alan LaMielle) #7

Based on your old post, it certainly looks like version 1.1 resulted in that output. But maybe there’s something going on there that I’m not aware of.

I like the ‘minimal by default’ approach so long as there is sufficient power to tweak the defaults. Clearly there is, I just need to go and write a bit of code to do what I want.

I don’t have a ton of spare time (who does) but if someone from the core dev team would be willing to point me in the right direction I may take a stab at something. How should we proceed from here?


(Peter Niederwieser) #8

In terms of figuring out what code needs to be changed, I’d start from ‘org.gradle.api.tasks.testing.Test#executeTests’. Perhaps this could be controlled by a boolean property on that class. In terms of the contribution process, check out https://github.com/gradle/gradle/blob/master/CONTRIBUTING.md


(Alan LaMielle) #9

Thanks, I’ll take a look!