Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Misleading string-ified test failure output #473

Open
dabrahams opened this issue Jan 10, 2024 · 3 comments
Open

Misleading string-ified test failure output #473

dabrahams opened this issue Jan 10, 2024 · 3 comments

Comments

@dabrahams
Copy link

When this test fails:

      XCTAssertEqual(g.rules.count, 1)

The output is

XCTAssertEqual failed: ("3") is not equal to ("1")

The quotes around the values are both needless and misleading; they give the impression that I was testing for string equality.

@grynspan
Copy link
Contributor

I think we'd still want the quotes for anything conforming to StringProtocol, but I agree they (and probably the parentheses too?) aren't immediately meaningful for other data types.

@abrarShariar
Copy link

abrarShariar commented Mar 24, 2024

The parenthesis might be helpful to separate out the value we are asserting vs. the logging text.

However, the quotes could be misleading because it wraps everything with quotes regardless to type..

Maybe we can include the data type in the assertion message too? So, the final output would look sth like this:

XCTAssertEqual failed: Int(3) is not equal to Int(1)
XCTAssertEqual failed: String("Hello World") is not equal to String("hello")

what does everyone think? @grynspan @dabrahams

I've taken my PR to draft while we discuss it

@grynspan
Copy link
Contributor

I don't morally object, though I know a lot of code that integrates with XCTest is sensitive to formatting changes. @briancroom what do you think?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants