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

Capture source location of elements in collection literal test arguments #519

Open
wwake opened this issue Jul 2, 2024 · 5 comments
Open
Labels
enhancement New feature or request

Comments

@wwake
Copy link

wwake commented Jul 2, 2024

Description

For parameterized tests, I'd like the error report to point to the source line of the failing test case (perhaps as well as the #expect that failed). This makes more sense for sequences of test cases than combinatorial tests.

In XCTest, I used a struct wrapping each test case that captured #file and #line, so I could pass those through to the assertions. (Sub-issue: there's no corresponding #sourceLocation macro so I can't capture the exact location.)

Wrapping each line was annoying. It would really be nice if there were an implicit way to get this information - e.g., automatically capture the source location for each test case, and add an argument or implicit value that you could pass to #expect.

Expected behavior

No response

Actual behavior

No response

Steps to reproduce

No response

swift-testing version/commit hash

No response

Swift & OS version (output of swift --version && uname -a)

No response

@wwake wwake added the enhancement New feature or request label Jul 2, 2024
@grynspan
Copy link
Contributor

grynspan commented Jul 2, 2024

For inputs like array or dictionary literals, we want to implement something here in a future update. In the general case, it's not possible (because source location information is only available for elements in collection literals.)

@grynspan
Copy link
Contributor

grynspan commented Jul 2, 2024

Separately, we did just add #_sourceLocation, although it's not in Xcode or in a tagged release yet.

@stmontgomery stmontgomery changed the title Better reporting for parameterized tests Capture source location of elements in collection literal test arguments Jul 2, 2024
@stmontgomery
Copy link
Contributor

I updated the title to scope the request a bit more narrowly to something we can actually achieve:

Capture source location of elements in collection literal test arguments

@stmontgomery
Copy link
Contributor

Tracked internally as rdar://130959475

@grynspan
Copy link
Contributor

grynspan commented Jul 2, 2024

I think we have an earlier radar?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Development

No branches or pull requests

3 participants