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

Adding test to existing file: Test with id /path/to/test/file.R&[object Object] could not be found. #29

Open
katrinabrock opened this issue Aug 22, 2024 · 2 comments

Comments

@katrinabrock
Copy link

Repro steps:

  • Run tests from the sidebar by clicking the play button that runs a file.
  • Add a test to that file.
  • Again click the play button that runs all tests in file (not individual tests).

Expected result: both tests run
Actual result: First test runs successfully. Second test doesn't run (from what I can tell). File is reported as failing with Test with id /path/to/test/file.R&[object Object] could not be found.

Video of issue:
https://github.com/user-attachments/assets/8227d538-98b3-4eb4-8f9b-f3eadc0a937e

Test file in question with surrounding repo can be found here:
https://github.com/katrinabrock/minimal-r-package/blob/main/tests/testthat/test-passes.R

@katrinabrock
Copy link
Author

katrinabrock commented Aug 26, 2024

I did some more digging. This happens when there are warnings or errors outside of a test_that(...) block.

in that case, no test or context are passed into add_result method and the result looks something like this:

List of 6
 $ message    : chr "The `code` argument to `test_that()` must be a braced expression to get accurate file-line information for failures."
 $ srcref     : 'srcref' int [1:8] 3 1 3 39 1 39 3 3
  ..- attr(*, "srcfile")=Classes 'srcfilecopy', 'srcfile' <environment: 0x55b7041aab38> 
 $ trace      :Classes ‘rlang_trace’, ‘rlib_trace’, ‘tbl’ and 'data.frame':     1 obs. of  5 variables:
  ..$ call     :List of 1
  .. ..$ : language test_that("Test #1", expect_true(TRUE))
  .. .. ..- attr(*, "srcref")= 'srcref' int [1:8] 3 1 3 39 1 39 3 3
  .. .. .. ..- attr(*, "srcfile")=Classes 'srcfilecopy', 'srcfile' <environment: 0x55b7041aab38> 
  ..$ parent   : int 0
  ..$ visible  : logi TRUE
  ..$ namespace: chr "testthat"
  ..$ scope    : chr "::"
  ..- attr(*, "version")= int 2
 $ start_frame: int 27
 $ end_frame  : num 28
 $ test       : chr "(code run outside of `test_that()`)"
 - attr(*, "class")= chr [1:3] "expectation_warning" "expectation" "condition"

The the VScodeReporter emits and undefined test like this:

{"type":"add_result","context":{},"test":{},"result":"warning","location":"test-passes.R:3:1","filename":"test-passes.R"}

Which then hits this condition:
https://github.com/meakbiyik/vscode-r-test-adapter/blob/master/src/testthat/runner.ts#L112

@meakbiyik
Copy link
Owner

meakbiyik commented Aug 26, 2024

Dear Katrina, thanks a lot for the detailed report! I will check it out as soon as possible, just a bit busy these days.

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

No branches or pull requests

2 participants