chevron-thin-right chevron-thin-left brand cancel-circle search youtube-icon google-plus-icon linkedin-icon facebook-icon twitter-icon toolbox download check linkedin phone twitter-old google-plus facebook profile-male chat calendar profile-male
0 votes
I want to ensure method XYZ was called exactly 6 do I do that (in both Natural and AAA)?

Same situation but I want to make sure it was call at minimum 1 time, any max...

Same situation but I want to make sure at max 12 times (could be 0 and bev valid)...
asked by boo (21.8k points)

3 Answers

0 votes

With AAA, there's no specific API for doing that. In Natural you can use recorder.Repeat, or any of the repeating overloads (like ExpectAndReturn).

The reason we've not done this in AAA, is that we believe that if you need to verify that, your test is over specified. The reason this is not so good, is that because over-specified tests are fragile. Fragile tests break with very small changes inside the production code, and when they do - you need to fix them. You don't want to spend your time maintaining tests.

Hope this helps,
answered by gilz (14.5k points)
0 votes
I would agree with that statement 98% of the time...but there's always an exception right? :)
answered by boo (21.8k points)
0 votes

You bet. And there are ways to deal with that. For instance, you can think if that's what you need to test, or maybe you can test this by proxy: verify or assert on another value that will tell you that the method was called 6 times.

It depends on the specific case you have. Would you like to post here the case so maybe I can suggest an alternative?

answered by gilz (14.5k points)