stretchr / testify

A toolkit with common assertions and mocks that plays nicely with the standard library
MIT License
22.52k stars 1.56k forks source link

Is it possible to assert for multiple allowed values? #1523

Closed red8888 closed 4 months ago

red8888 commented 6 months ago

I have a test that is semi-nondeterministic. I know thats generally bad but I just want to allow 2 possible values. Does testify support this?

Ie I'm looking for something like: testSuite.Equal(<ALLOWED_VALUE_ONE> | <ALLOWED_VALUE_TWO>, <ACTUAL_VALUE>)

Is there support for this?

hendrywiranto commented 6 months ago

Hi! can you use assert.Contains ? https://github.com/stretchr/testify/blob/master/assert/assertions.go#L886

brackendawson commented 4 months ago

If this suggestion doesn't work for you, please do comment again or start a discussion (tab up top).