Disable Ginkgo warning of "slow test"

1.2k Views Asked by At

I am using Ginkgo to execute some relatively long-running integration tests. Interspersed with my test output is the occasional warning that my tests are taking too long to execute:

• [SLOW TEST:30.000 seconds]

Is there a way to disable these warnings when running Ginkgo through the standard Go testing library? The documentation mentions a parameter (--slowSpecThreshold=TIME_IN_SECONDS) for the Ginkgo test runner, but doesn't seem to mention how to achieve the same programmatically.

2

There are 2 best solutions below

0
On BEST ANSWER

With Ginkgo v2, the config.DefaultReporterConfig variable has been deprecated (see also the migration guide) and cannot be used anymore to configure the "slow spec threshold".

To configure said threshold in Ginkgo v2, pass a types.ReporterConfig parameter into your RunSpecs call:

RunSpecs(t, "your test suite", types.ReporterConfig{
    SlowSpecThreshold: 10 * time.Second,
})
3
On

Ginkgo handles its configuration in the github.com/onsi/ginkgo/config package, where the runtime configuration is available for modifications.

Making Ginkgo far more patient can be achieved with:

config.DefaultReporterConfig.SlowSpecThreshold = time.Hour.Seconds()