GREYMatcher

@protocol GREYMatcher <NSObject>

Matchers are another way of expressing simple or complex logical expressions. This protocol defines a set of methods that must be implemented by every matcher object.

  • A method to evaluate the matcher for the provided @c item.

    Declaration

    Objective-C

    - (BOOL)matches:(id)item;

    Swift

    func matches(_ item: Any!) -> Bool

    Parameters

    item

    The object which is to be evaluated against the matcher.

    Return Value

    @c YES if the object matched the matcher, @c NO otherwise.

  • A method to evaluate the matcher for the provided @c item with a description for the issue in case of a mismatch.

    Declaration

    Objective-C

    - (BOOL)matches:(id)item
        describingMismatchTo:(id<GREYDescription>)mismatchDescription;

    Swift

    func matches(_ item: Any!, describingMismatchTo mismatchDescription: Any!) -> Bool

    Parameters

    item

    The object which is to be evaluated against the matcher.

    mismatchDescription

    The description that is built or appended if the provided @c item does not match the matcher.

    Return Value

    @c YES if the object matched the matcher, @c NO otherwise. In case of a mismatch, the reason for mismatch is added to @c mismatchDescription.

  • A method to generate the description containing the reason for why a matcher did not match an item.

    @remark This method assumes that GREYMatcher::matches: is false, but will not check this.

    Declaration

    Objective-C

    - (void)describeMismatchOf:(id)item to:(id<GREYDescription>)mismatchDescription;

    Swift

    func describeMismatch(of item: Any!, to mismatchDescription: Any!)

    Parameters

    item

    The object which is to be evaluated against the matcher.

    mismatchDescription

    The description that is built or appended if the provided @c item does not match the matcher.

  • A method to generate a description of an object.

    Declaration

    Objective-C

    - (void)describeTo:(id<GREYDescription>)description;

    Swift

    func describe(to description: Any!)

    Parameters

    description

    The description that is built or appended.