Использование tryCatch с testth запускает тест дважды
Допустим, у меня есть тест в моем пакете, который делает следующее
context("Example test")
test_that("Test failure tryCatch", {
reporter <- with_reporter(
"silent",
tryCatch({
expect_identical(1, "hello")
},
expectation_failure = function(e) {
cat("\n This is an imformative message\n")
}
)
)
expect_identical(1, "hello")
})
Это дает следующий вывод
> testthat::test_file(path = "./tests/testthat/test-tmp.R")
✔ | OK F W S | Context
⠏ | 0 | Example test
This is an imformative message
✖ | 0 1 | Example test
───────────────────────────────────────────────────────────────────────────────────────────────────────────────
test-tmp.R:15: failure: Test failure tryCatch
1 not identical to "hello".
Types not compatible: double is not character
───────────────────────────────────────────────────────────────────────────────────────────────────────────────
══ Results ════════════════════════════════════════════════════════════════════════════════════════════════════
OK: 0
Failed: 1
Warnings: 0
Skipped: 0
В идеале я не хочу, чтобы контекст печатался дважды. Как сделать тестовый прогон таким, чтобы линия
⠏ | 0 | Example test
заменяется
✖ | 0 1 | Example test
вместо выхода у меня сейчас есть?