Cuckoo icon indicating copy to clipboard operation
Cuckoo copied to clipboard

Enable OCMock's `OCMQuantifier` for `objcVerify` function

Open ajpallares opened this issue 3 years ago β€’ 5 comments

Added support for OCMQuantifier to objcVerify function.

This PR fixes #366

ajpallares avatar Mar 07 '22 10:03 ajpallares

Even though OCMock verifies by default that the method has been called at least once (see Quantifiers in OCMock docs), I set the default OCMQuantifier to .exactly(1) in objcVerify in order for it to behave the same as Cuckoo's verify, which defaults to the times(1) CallMatcher.

Let me know if this needs to be changed.

ajpallares avatar Mar 07 '22 10:03 ajpallares

This is a great addition! I can't believe we missed this during initial implementation. I agree with merging this, though I'd like to ask you to include some tests with various quantifiers as well, please. πŸ™‚

MatyasKriz avatar Mar 10 '22 18:03 MatyasKriz

I'm not sure about the default OCMQuantifier being .exactly(1). There's no doubt it is consistent with Cuckoo's default CallMatcher also being times(1). However, prior to this PR, objcVerify was actually checking against .atLeast(1) quantifier.

Because of this, existing tests might need to change after this PR, which, indeed, was necessary for the tests in Cuckoo (see this commit). It can be annoying and confusing for Cuckoo users to realize tests are failing after updating Cuckoo's version.

WDYT @MatyasKriz?

Other than that, I've added the requested tests.

ajpallares avatar Mar 14 '22 07:03 ajpallares

Hmm, I see. That's a very good point. Unfortunately I don't have the analytics to see how much of an impact that would make. But yeah, we shouldn't include this change in a minor version update. I'll merge this in just before the next major update drops, but thanks a lot for noticing and implementing this!

MatyasKriz avatar Mar 17 '22 17:03 MatyasKriz

@MatyasKriz @ajpallares did you think about merging this PR in a minor version with the slight change of matching the current behavior?

Avoiding the behavior change could be done in 2 different ways in my opinion:

  • A: setting the default value to .atLeast(1)
  • B: define objcVerify two times, once without a quantifier for keeping the current behavior intact and once with quantifier where one can explicitly define it

The outcome of both would be the very same and would allow shipping it in a minor version update.

Another PR could be opened with the current implementation of the PR where the default value matches to CallMatcher and would be shipped in next major version update.

rolandkakonyi avatar Aug 08 '22 09:08 rolandkakonyi

* A: setting the default value to `.atLeast(1)`

I suppose that this is a nice enough solution to deliver the core feature of this PR. I'd then immediately create another PR that would change this to .exactly(1) that we could then merge for the next major update. πŸ™‚

MatyasKriz avatar Aug 12 '22 17:08 MatyasKriz

@ajpallares I've rebased the relevant changes according to @rolandkakonyi's suggestion while leaving the PR that makes the quantifier consistent with Cuckoo's verify for when the next major version is released. This PR is already merged, so it can be closed and I'll release a new version in a minute. πŸ™‚

MatyasKriz avatar Aug 16 '22 14:08 MatyasKriz

That’s great! Thank you all πŸ™ŒπŸΌ

ajpallares avatar Aug 16 '22 16:08 ajpallares