Skip to content

testthat unit tests are failing when using mocks with httptest2. #29

@mccroweyclinton-EPA

Description

@mccroweyclinton-EPA

I have noticed that when unit tests are ran using the RStudio Test button in the Environment/History/Connections/Build/Git/Tutorial pane sometimes unit test work, but when running unit test using testthat::test_local() most of the time unit test fail. The results are not predictable as far as I can tell. Sometimes it works, and other times the test don't work.

@mpadge has suggested that the issue is probably related to testthat2's redaction facilities (inst/httptest2/redact.R). I am in agreement with @mpadge's suggestion, in particular, I believe that this issue is related to the two calls to

getOption()

on lines 10 and 11. My initial thoughts are that for some reason, in some contexts, these two function calls are not returning the expected results.

Here is the output from a failed run:

Running the tests in 'tests/testthat.R' failed.
Last 13 lines of output:
2. └─testthat::expect_no_error(.)
── Failure ('test-bystate.R:150:5'): bystate functions ─────────────────────────
Expected . to run without any errors.
i Actually got a <purrr_error_indexed> with text:
i In index: 1.
Caused by error in gsub():
! zero-length pattern
Backtrace:

1. ├─... %>% expect_no_error() at test-bystate.R:150:5
2. └─testthat::expect_no_error(.)

 [ FAIL 73 | WARN 0 | SKIP 0 | PASS 26 ]
 Error: Test failures
 Execution halted

Metadata

Metadata

Labels

bugSomething isn't working

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions