tmp <- tempfile()
# The first run always succeeds
expect_known_output(mtcars[1:10, ], tmp, print = TRUE)
# Subsequent runs will succeed only if the file is unchanged
# This will succeed:
expect_known_output(mtcars[1:10, ], tmp, print = TRUE)
if (FALSE) {
# This will fail
expect_known_output(mtcars[1:9, ], tmp, print = TRUE)
}
Run the code above in your browser using DataLab