echocat / gradle-golang-plugin

Gradle plugin to build, test and do other stuff of Golang projects.
https://github.com/echocat/gradle-golang-plugin
Mozilla Public License 2.0
44 stars 8 forks source link

go test output #11

Closed sbulman closed 7 years ago

sbulman commented 7 years ago

It would great to add an option to be able to write the test results out in junit format. This is a fairly common format for CI systems. Perhaps at a minimum an option could be added to stream the output of go test into a file that could subsequently be used as input into other tools e.g. https://github.com/jstemmer/go-junit-report

blaubaer commented 7 years ago

Hi @sbulman!

This makes totally sense. I will have a look at this. But the question is, what will be the default behavior?

sbulman commented 7 years ago

Perhaps the default behavior should be 'as is' - i.e. the plugin swallows the output from go test. A couple of options could be added:

  1. Stream output of go test to a file. This could be done in a similar fashion to the coverage output. It's probably most useful to use the -v (--verbose) option for this.
  2. Write a junit format file. Again this might be done in a similar fashion to the coverage, where a 'junit file' is specified in the settings.

I'm not sure if it would be possible to allow both options or if they are mutually exclusive. I'm also not sure if for (2) whether go-junit-report can be 'installed' automatically or whether this has to be defined as an explicit dependency in the gradle.build file (either would be fine from my perspective).

Thanks for taking a look.

checketts commented 7 years ago

I'm interested in the junit output as well. I'm still quite new to using this plugin, so I'll likely have more feedback after using it in a bit more complete project. However it would be great to just be able to leverage the test reports config (that is built into gradle):

As mentioned here:

test {
    reports {
        junitXml.enabled = true
    }               
}
blaubaer commented 7 years ago

Storing of the test output and generating of junit-report is now enabled by default and could be configured under:

golang {
    testing {
        // Will write the test output in the specified file.
        // If set to null this file will not be written.
        log = "${buildDir}/testing/test.log" // String

        // Will write the test output in JUnit report format in the specified file.
        // If set to null this file will not be written.
        junitReport = "${buildDir}/testing/junit_report.xml" // String
    }
}