onsi / ginkgo

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

support outputting the time spent on each spec #1421

Closed haohanyuzmx closed 1 month ago

haohanyuzmx commented 1 month ago

I skimmed through the documentation and found that some slow test alerts, such as PollProgressAfter, used to output "slowtest" in previous versions, but PollProgressAfter needs to be set manually and "slowtest" has been removed. I couldn't find a way to output the time spent on all specs, which would be great if it were possible. Of course, it's also possible that I didn't read carefully enough, so please point out if this idea is problematic.

onsi commented 1 month ago

hey @haohanyuzmx - yes the SLOW test indicator was removed with Ginkgo 2.0. I recommend running

ginkgo --poll-progress-after=X

where X is the threshold duration you want to set (e.g. X=60s). Now if a spec takes longer than 60s Ginkgo will emit a progress report which will tell you which spec is slow and dump the goroutines and show you exactly which line is slow (this is much more useful than the previous behavior).

Note that once the threshold is passed Ginkgo will repeatedly poll the spec every 10s, emitting an additional progress report each time. If this is too noise you can do something like:

ginkgo --poll-progress-after=60s --poll-progress-interval=60m

hope that helps.