I tend to wrap tests for messages or warnings around tests like expect_true() to prevent having to write (and execute) the same test twice. For example:
library(tinytest)
be_FALSE <- function(x) {
message("I'm FALSE")
FALSE
}
expect_message(expect_true(be_FALSE(x)))
# ----- PASSED : <-->
# call| expect_message(expect_true(be_FALSE(x)))
But in interactive use this indicates the tests pass whereas in reality the expect_true() test fails. However, the tests do fail when using tinytest::run_all(). Re-reading the documentation it seems this wrapping tests is undocumented, so I'm wondering if I should expect it to work at all.
So my question is: can something be done to make the test also fail when run interactively, or should I just change my code to split the tests:
library(tinytest)
expect_true(be_FALSE(x))
# I'm FALSE
# ----- FAILED[data]: <-->
# call| expect_true(be_FALSE(x))
# diff| Expected TRUE, got FALSE
expect_message(be_FALSE(x))
# ----- PASSED : <-->
# call| expect_message(be_FALSE(x))
I'm using tinytest 1.4.3 with R 4.6.0 on Windows 11 x64
I tend to wrap tests for messages or warnings around tests like
expect_true()to prevent having to write (and execute) the same test twice. For example:But in interactive use this indicates the tests pass whereas in reality the
expect_true()test fails. However, the tests do fail when usingtinytest::run_all(). Re-reading the documentation it seems this wrapping tests is undocumented, so I'm wondering if I should expect it to work at all.So my question is: can something be done to make the test also fail when run interactively, or should I just change my code to split the tests:
I'm using
tinytest1.4.3 with R 4.6.0 on Windows 11 x64