Test functions that require a database connection

I would like to use testthat to test functions that require an authenticated database connection. I am using the rstudioapi::askForPassword() function to get the password in the process of creating a database connection.

However when I run my devtools::test() I get an error that "RStudio is not running".
I guess the tests occur in a new R session that cannot access rstudioapi::askForPassoword().
It would be nice if I could create the connection once and use it in all my tests.

Any ideas about how to test code in a package that requires an authenticated database connection?

It seems like using the getPass::getPass() function instead of rstudioapi::askForPassoword() solves this problem.