Page 1 of 1

expectCallCount(..) but only with specific arguments?

Posted: Sun Dec 10, 2006 5:18 am
by Chris Corbyn
SimpleTest of course :)

I can make an expectation about a single call with a known set of arguments. I can make an expectation about a minimum, maximum of fixed call count on a method. I can make an expectation about the arguments given at a known call time on a method. But how can I more broadly just say that I expect method A to be called 3 times with argument B? The method may be called any number of times with other arguments but only 3 times with these certain arguments.

I can't see a way to do it without committing myself to the exact time it will be called using expectAt(..)... I'll do this but it feels a bit too likely to break as the code evolves even if technically what's happening is correct. Is it possible to do what I want?

Posted: Mon Dec 11, 2006 3:32 am
by Maugrim_The_Reaper
I think this is one for the SimpleTest mailing list - or a lot of source code reading...

Posted: Mon Dec 11, 2006 4:30 am
by Chris Corbyn
Maugrim_The_Reaper wrote:I think this is one for the SimpleTest mailing list - or a lot of source code reading...
Well I had a poke around and found that essentially things like expectOnce() and expect() all just operate by running combinations of the other expectations. For example, expectOnce() with expect arguments just calls expect() right after it's checked if expectCallCount(..., 1) is ok.

The problem with what I was looking to do is that none of the methods already there actually have the ability to do what I need. That said, all the data is stored nicely so it would be easy to "hack" it in. I may have a look at changing expectCallCount() to allow an argument expectation to be given purely for my own interest :)

Posted: Mon Dec 11, 2006 5:31 am
by Maugrim_The_Reaper
That may still make it something for the mailing list, or a small patch request if you get around to it ;).