Skip to content

Allow custom messages in expect() #596

Closed

Description

@clayreimann
  • I have read CONTRIBUTING and have done my best to follow them.

What did you do?

for (tag, title) in defaultRows {
    let row = entryForm.row(tag: tag)
    expect(row.exists) == true
    expect(row.staticTexts["title"].label) == title
}

What did you expect to happen?

I would like to be able to provide custom message to expect so that I can see which loop iteration failed.

for (tag, title) in defaultRows {
    let row = entryForm.row(tag: tag)
    expect(row.exists, message: "\(tag) exists") == true
// or maybe more briefly
//    expect(row.exists, "\(tag) exists") == true
    expect(row.staticTexts["title"].label) == title
}

I'd be willing to submit a PR if this feature fits with the project

Environment

List the software versions you're using:

  • Quick: Nope
  • Nimble: 7.1.3
  • Xcode Version: 9.4.1 (9F2000)
  • Swift Version: Xcode Default
  • Carthage: 0.30.1

Activity

  1. ikesyo commented on Aug 18, 2018

    @ikesyo
    Member

    The functionality is provided by to(_:description:)

    expect(1).to(MatcherFunc { _, _ in false }, description: "These aren't equal!")

  2. clayreimann commented on Aug 18, 2018

    @clayreimann
    Author

    Which is incompatible with the infix operators. Chai provides a similar api for their assertions that aren't function calls.

  3. clayreimann commented on Sep 17, 2018

    @clayreimann
    Author

    @ikesyo Any comment on this? Would such a PR be accepted?

  4. ikesyo commented on Sep 17, 2019

    @ikesyo
    Member

    It seems that this would be important with regard to #493.

  5. self-assigned this
    on May 6, 2020
  6. ikesyo commented on May 6, 2020

    @ikesyo
    Member

    I'm now working on this in relation to #369 and #742.

  7. locked and limited conversation to collaborators on May 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions