Skip to content

Conversation

@eisandbar
Copy link

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

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.
@dolmen dolmen added bug pkg-suite Change related to package testify/suite labels Oct 30, 2023
@dolmen
Copy link
Collaborator

dolmen commented Jun 2, 2025

Is it fixed?

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

@dolmen dolmen added the internal/testing Changes purely related to the testify testsuites label Jun 2, 2025
@dolmen dolmen changed the title Fixed FailfastSuite failing when test.count > 1 suite: fix FailfastSuite failing when test.count > 1 Jun 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug internal/testing Changes purely related to the testify testsuites pkg-suite Change related to package testify/suite

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants