5

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.

Henrik Aasted Sørensen
  • 6,966
  • 11
  • 51
  • 60

2 Answers2

4

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()

Henrik Aasted Sørensen
  • 6,966
  • 11
  • 51
  • 60
  • Where did you set this field exactly? I've tried setting it in my `func TestFoo(t *testing.T)` function, and in `BeforeSuite`, and whilst I can assert that the field has the right value, I'm still seeing slow test warnings. – DeejUK Nov 02 '20 at 12:41
  • 1
    @EngineerBetter_DJ: I'm setting it in the `TestSuite` setup function, where I also register before- and after-handlers etc. – Henrik Aasted Sørensen Nov 02 '20 at 12:45
  • 1
    Ha - so the reason I was getting confused is that it turns out that this doesn't work when running Ginkgo with `-p` for parallel test running! Thanks for your help. – DeejUK Nov 02 '20 at 14:58
3

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,
})
helmbert
  • 35,797
  • 13
  • 82
  • 95