Cuckoo custom matcher failure message

52 Views Asked by At

I use Cuckoo for mocking and stubbing. Is there any way to improve failure messages if custom ParameterMatcher fails?

Let's say (for sake of simplicity) I want to create a custom matcher for [AnyHashable: Any]:

func equalToCustomDictionary() -> ParameterMatcher<[AnyHashable: Any]> {
    ParameterMatcher { dictionary in
        guard let identifier = dictionary["id"] as? String else {
            return false
        }
        return identifier == "123" // identifier is "123ewq"
    }
}

when I call it:

verify(mock).saveDictionary(equalToCustomDictionary())

I see a failure message:

testFunctionName(): failed - Wanted 1 times but not invoked

which is not helpful to be honest. It forces me to check the test implementation and look what might fail. Whether it was a different object (or one of its properties) or indeed function wasn't called (as stated in the failure message)

I would expect a similar message to failing XCTEqual assertion:

testFunctionName(): XCTAssertEqual failed: ("123ewq") is not equal to ("123")

I shallowly checked a repository, issues, docs, SoF, and didn't see anything related.

0

There are 0 best solutions below