cucumber / godog

Cucumber for golang
MIT License
2.22k stars 250 forks source link

Support multiple formatter outputs to different locations #518

Closed jasondborneman closed 1 year ago

jasondborneman commented 1 year ago

🤔 What's the problem you're trying to solve?

Currently (AFAIK) you can only define a single --godog.format output for your tests. Ideally you could define multiple outputs, one for stdout to the command line and any number of other outputs to files.

This would be useful so that, for example, you run tests as part of CI/CD and can see --godog.format=pretty on the command line output, but send --godog.format=junit:file.xml to the file and BOTH would work.

✨ What's your proposed solution?

Support multiple format options. Maybe something like this on the command line:

$ go test --godog.format=pretty:stdout --godog.format=junit:file.xml

This would send pretty format to stdout but send the junit report to a file.

⛏ Have you considered any alternatives or workarounds?

I tried gotestsum as a solution, but its junit reports seem... iffy. They show 0 tests and a failure just shows all output in the testcase block. The junit reports that come with godog natively are MUCH better and would like to use those instead.

📚 Any additional context?

Feel free to contact me in the comments here to clarify anything that is needed. This would be a huge level up for what we're trying to do! Maybe there's already a way to do this and I just missed it since I'm new to godog. Thanks!

vearutop commented 1 year ago

It is not properly documented, but this is already possible with comma-separated values.

Please try:

$ go test --godog.format=pretty:stdout,junit:file.xml
jasondborneman commented 1 year ago

You rock, @vearutop! Although it looks like it actually needs to be:

$ go test --godog.format=pretty,junit:file.xml

No :stdout, but other than that it works a charm. I should have tried that!