testify icon indicating copy to clipboard operation
testify copied to clipboard

Add func similar to `AssertExpectations` which does not fail the test

Open pmalek opened this issue 8 months ago • 1 comments

Description

Out test suite uses AssertExpectations(t TestingT) bool which is great to ensure that all expected calls have been met.

It has a small issue though when working with eventually consistent code (like Kubernetes controllers): one cannot use it to wait for the expectations to get fulfilled because it fails the test.

Proposed solution

Add CheckExpectations() bool or CheckExpectations(t TestingT) bool which will not fail the test when some expectations where not met. This will allow callers to use e.g. require.Eventually() / require.EventuallyWithT() with that newly added function.

Use case

AssertExpectations() with eventually consistent code.

pmalek avatar Feb 28 '25 15:02 pmalek