-
Notifications
You must be signed in to change notification settings - Fork 341
Closed
Labels
bugan unexpected problem or unintended behavioran unexpected problem or unintended behavior
Milestone
Description
This might be related to issue #693
For testing our packages we are double checking the message from as.expectation.logical and printing it out by
rec <- 2
exp <- 2
expect_equal(
rec,
exp,
message=glue("Expect equal: \"Received\":\"{rec}\", \"Expected\":\"{exp}\"")
)and basically parse the information given in the message to show it to the users in a test report. We can create a table with the info:
data.frame(
success = "expectation_success" %in% class(expec),
received = stringr::str_extract(expec$message,"(?<=Received\"\\:\")[^\\,]*(?=\\\")")
expected = stringr::str_extract(expec$message,"(?<=Expected\"\\:\")[^\\,]*(?=\\\")")
)
>success received expected
> TRUE 2 2This went great in testthat <2.0. Now the expect as.expectation.logical destroys the message in case of success.
as.expectation.logical <- function(x, message, ..., srcref = NULL, info = NULL) {
type <- if (x) "success" else "failure"
message <- if (x) "success" else add_info(message, info)
expectation(type, message, srcref = srcref)
}we just receive
>success received expected
> TRUE "" ""
Could you plugin an option into the API to always give the failure message? Or is there a way to put our message anywhere else, e.g. into srcref?
A proposal by the RTest team is to provide an option such as allMessages:
as.expectation.logical <- function(x, message, ..., srcref = NULL, info = NULL) {
type <- if (x) "success" else "failure"
message <- if (x && !getOption("allMessages", default = FALSE)) "success" else add_info(message, info)
expectation(type, message, srcref = srcref)
}stoettnw, s-erhardt and potapovs
Metadata
Metadata
Assignees
Labels
bugan unexpected problem or unintended behavioran unexpected problem or unintended behavior