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

Verify records Swift Testing issue with source location. #369

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Stannieman
Copy link

Verify failed silently in Swift Testing because it does not pick up XCTAssert failure used in MockyAssert.
This PR uses Swift Testing's Issue.record IF running inside a Swift Testing test. Additionally there is a bunch of changes to make the error show at the correct place in source in the editor.

@Stannieman Stannieman force-pushed the Swift_Testing_support branch 2 times, most recently from 7424de3 to 4245adf Compare February 14, 2025 20:23
}
return
}
#endif
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The part above is the only thing that's needed to make the test correctly fail in Swift Testing. All the rest is just to make it show in the editor.

#endif

#if canImport(XCTest)
XCTAssert(expression(), message(), file: filePath, line: line)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed file to filePath here because XCTAssert's default parameter is #filePath as well. Is this a correct thing to do? It still shows up at the correct place in source in the editor.

@Stannieman Stannieman marked this pull request as ready for review February 14, 2025 20:25
@Stannieman Stannieman force-pushed the Swift_Testing_support branch from 4245adf to 5b23428 Compare February 14, 2025 20:32
@iamrado
Copy link

iamrado commented Mar 21, 2025

Great to see this, thanks @Stannieman!

@spaluchiewicz any help on getting this in is much appreciated.

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

Successfully merging this pull request may close these issues.

None yet

2 participants