tinytest
tinytest copied to clipboard
Testing internal functions with test_file as well as build_install_test
This is a question, not a bug.
I write a test function for an internal function in a testfile, I use the :::
-approach for the function and use build_install_test()
.
But if I only use test_file
for this internal function, it does not work as the package is not installed or an older version. Also I cannot simply load the function in the global environment, as the three colons let R
search for the package.
So how can I tackle this problem: using test_file()
as well as build_install_test()
for internal functions?
hmm, I don't think I ever used that workflow as I tend to only test functions that are exposed to the user, but I see your point. I can't think of a quick workaround. Perhaps you could use pkgload::load_package()
and then run test_file
? (disclaimer: I never use pkgload, so I have no idea if that would work)
So I tried using pkgload::load_all()
before the test_*
-function, so I could run the tests without :::
. This works, but then the build_install_test()
function does not work anymore. Maybe I could use a conditional test, but right now I cannot think of a good condition.