onsi / ginkgo

A Modern Testing Framework for Go
http://onsi.github.io/ginkgo/
MIT License
8.12k stars 644 forks source link

[Question] Custom reports to tie across all suites in a ginkgo run #1293

Closed anoop2811 closed 9 months ago

anoop2811 commented 9 months ago

Hey Onsi, I am trying to make a custom reporter that would emit information into a database for a single run of the ginkgo cli. Since we have suites that are scoped per package, how do I tie the Report type in each ReportAfterSuite into a single ginkgo run ? Is there a way to pass that across a single run so that I can tied all the data to a run?

onsi commented 9 months ago

hey @anoop2811 !

To reflect it back: you (or, really, CI) are invoking ginkgo -r across a bunch of packages and generating reports for each package (or, even, a single report that combines the reports of each package) and you'd like to find a mechanism to correlate which reports are grouped together with a given run?

One option is to key off of the random seed (report.SuiteConfig.RandomSeed), which is guaranteed to be the same for all packages tested in a single ginkgo -r invocation. Another is to inject the information yourself with, say, an environment variable that includes a unique identifier (e.g. the timestamp, or a uuid or something) and then have your custom reporter attach that to the report you put in the database.

anoop2811 commented 9 months ago

Thanks much @onsi !!! RandomSeed sounds like the solution I would prefer :)