testwhat
testwhat copied to clipboard
Templated messages
@filipsch A lot of times I see custom messages that simply use a different template from the default and hence are NOT completely custom. Here is an example:
ex() %>%
check_function('str_detect') %>%
check_argument(
'string',
"Did you remember to specify the `string` argument in this call to `str_detect()`?")
) %>%
check_equal(
incorrect_msg = "The `string` argument in your `str_detect()` call is incorrect.",
append = FALSE
)
I see two ways we can make writing such messages a lot easier:
1 | Allow instructors to specify a template to these functions instead of a string. For example a glue
template could be
Did you remember to specify the
{arg}
argument in this call to{fun}()
?"
2 | We can predefine a set of templates in testwhat
and randomly select one while reporting. This will possibly reduce SCT fatigue by adding variation to the messages at little cost. I am a big fan of this approach.
cc @martijnsublime @ncarchedi
@ramnathv This is what you can already do in pythonwhat
(although it's not actively documented), and it could make sense to do it in testwhat
as well. Worth considering.
@filipsch Mm did not know about the hidden easter egg in pythonwhat
:) I have not analyzed the data on custom messages yet, but it seems like most of the time they are just variants of a template.