Proposal Details
In golang 1.21.0 a new Testing function was added to the "testing" package. I propose a similar and new Count function which along the same lines, returns the test.count value for the test. Implementation is similar to Short shown here:
// Short reports whether the -test.short flag is set.
func Short() bool {
if short == nil {
panic("testing: Short called before Init")
}
// Catch code that calls this from TestMain without first calling flag.Parse.
if !flag.Parsed() {
panic("testing: Short called before Parse")
}
return *short
}
This would be very useful to allow a test to perform some more expensive global setup only once if it's going to be run multiple times, for example. Or to know how much longer we expect a test to last. (Eg: time*count)
Thanks!