Skip to content

Conversation

@kubajal
Copy link
Contributor

@kubajal kubajal commented Aug 15, 2025

Currently, there is no way to report the line number of tests in reporters. This PR enables that.

This PR follows the logic of e.g. LocationReporter which prints the srcref of all expect_* assertions. It extends this behavior by also reporting locations of test_that, describe and it expressions.

With minimal effort, this PR enables #2184.

@kubajal kubajal force-pushed the feature/expose_srcref_in_start_test branch from 4be00d6 to 96489ce Compare August 15, 2025 15:05
@kubajal kubajal force-pushed the feature/expose_srcref_in_start_test branch 3 times, most recently from 817eb5c to 2ee85c7 Compare August 16, 2025 08:18
@kubajal kubajal marked this pull request as ready for review August 16, 2025 09:43
@kubajal
Copy link
Contributor Author

kubajal commented Aug 20, 2025

@hadley any chance of this getting merged?

@hadley
Copy link
Member

hadley commented Aug 27, 2025

I've fixed the style issue, re-used the srcref standard display, and added a test specifically for nested tests. But this PR introduces some confusion because find_expectation_srcref() already looks up the srcref, but of the test_that() call, rather than the srcref of the code inside of it. Computing slightly different srcrefs in two different ways seems like a recipe for confusion.

@hadley
Copy link
Member

hadley commented Aug 28, 2025

I've thought it over a bit more, and it doesn't feel like a good fit for testthat to me. I've done most of the work to make it maintainable for me over the long term, but it still feels a bit fragile and I'm not fully sold on the motivation.

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.

2 participants