How to test that an error does not occur?
I am starting to implement testing for an R package, and have been using the
testthat package. Note that I am new to testing, so perhaps my approach is off.
I have a function that currently fails the 16th time it is executed, and before fixing this, I want to write a regression test that will catch it if it re-appears.
e.g., the following always throws the same error message:
for i in (1:17) myfun()
myfun does not return anything, it only has a side-effect of opening a database connection. It is clear to me that I can write a test that expects an error and passes if it is returned:
expect_error(for (i in 1:17) myfun())
But I don't quite get how to write a test to ensure that the error does not occur. As it is not obvious, perhaps my approach is wrong. I can figure out how to write more specific tests, but I would like to start with this one.
What type of test would I write to make sure that such an error does not appear?