testify icon indicating copy to clipboard operation
testify copied to clipboard

suite: fix FailfastSuite failing when test.count > 1

Open eisandbar opened this issue 3 years ago • 1 comments

FailfastSuite used a callOrder slice that gets populated by the suite methods and compared it to a string literal. When test.count is > 1 callOrder is overpopulated and does not match the expected string. Fixed this by having TearDownSuite dump the callOrder into a new slice callOrderPerRun and have tests assert each run separately.

Summary

Fixes TestFailfastSuite failing when test.count is set > 1

Changes

FailfastSuite now dumps callOrder into callOrderPerRun when TearDownSuite is called. TestFailfastSuite now compares the string literal to each entry of callOrderPerRun

Motivation

Previously running go test ./... test.count=2 resulted in failure

Related issues

eisandbar avatar Aug 08 '22 19:08 eisandbar

Is it fixed?

$ go test ./suite -count=2
ok  	github.com/stretchr/testify/suite	9.404s

dolmen avatar Jun 02 '25 09:06 dolmen