I also couldn't find a canonical recommendation for testing a deprecated function (e.g. the section of r-pkgs on deprecated functions doesn't mention unit tests), but I agree with you it is a good idea to continue testing until the function is removed entirely.
Here are two ideas:
-
Suppress the warnings in the unit tests with
suppressWarnings(). Depending on how many tests you have, this will require a lot of search and replace. If the tests are spread across multiple files, you could use the RStudio addin Replace in Files. I also did some searching online, and the one post I found also recommended usingsuppressWarnings(). -
Have the deprecated function check to see if it is being tested before issuing the deprecation warning. If you are using testthat, you can check for the environment variable
TESTTHAT. Thus it could look something like this:if (!identical(Sys.getenv("TESTTHAT"), "true")) .Deprecated("other_function")