objective c - Returning custom description and debugDescription values for mock objects -
i use ocmock excellent ochamcrest matchers. encounter test failure messages aren't helpful be. because ochamcrest output relies heavily on value returned "description" method of objects ocmockobject's default description implementation generic.
is there recommended way have mock objects return custom description?
i've tried stubbing "description" method on mock objects doesn't seem work.
as workaround i've created occlassmockobject+description
category extension adds setmockdescription:
method, i'm hoping there's more officially supported solution. (if not, maybe i'll polish mine , submit pull request.)
here examples of of results i'd improve...
example assertion #1
assertthat(recommendedsong, is(mocksong1));
failure message:
expected <ocmockobject[songbar]>, <ocmockobject[songbar]>
example assertion #2
assertthat(playlist.songs, contains(mocksong1, mocksong2, nil));
failure message:
expected collection containing [<ocmockobject[songbar]>, <ocmockobject[songbar]>], item 0: <ocmockobject[songbar]>
Comments
Post a Comment