-
Notifications
You must be signed in to change notification settings - Fork 17
Treat test_that()
tests as document symbols
#856
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
base: bugfix/section-symbols
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be interesting to add a test where there are comments that basically section the tests into different blocks. Like this:
https://github.com/tidyverse/forcats/blob/main/tests/testthat/test-lvls.R
Also just a side note: the test explorer (which is a positron-r matter) needs to gain a way to register test_that()
-like functions, i.e. if a user or an R package creates a wrapper that basically quacks like test_that()
and should be treated accordingly by machinery like this. Whenever that happens, we'd probably want to try to make breadcrumbs also work. posit-dev/positron#7213
I was thinking the same! Almost implemented it as a TS query as queries would probably be the way to make it generic. It'd be nice to share the same configurability for document symbols and the test infra. |
I've now expanded the test with a second section. |
68df2ed
to
1b58bb0
Compare
74dbe94
to
a5b9485
Compare
I took this for a little test drive in gargle. I'm wondering if we might just want to stop at the top-level I guess having them in the outline view is fine, because they can be collapsed. The problem of overabundance seems to hurt more in when using the command palette to search for a symbol. Screen.Recording.2025-07-01.at.4.53.52.PM.mov |
@jennybc I think we want to recurse to support things like sections inside But regarding how busy the outline currently feels I think this will be mostly solved by this: posit-dev/positron#8330 |
Addresses posit-dev/positron#1428.
test_that()
blocks are now recorded as document symbols. This enables the following features:@
prefix in the command palette)The tests are registered with "Test: " prefix, followed by the test title.
I've purposely not made them workspace symbols, so you can't search for tests across files with a workspace symbol search (
#
prefix in the command palette). The markdown extension does that for markdown sections and I find it gets in the way a lot when searching for variables and functions.QA Notes
I've added backend side tests.
On the frontend with:
You should see
Test: foo
:Screen.Recording.2025-06-26.at.16.40.37.mov