With information gathered from the R Backend, testwhat can detect whether the student's submission generated an error.

check_error(state, ...)

# S3 method for default
check_error(state, incorrect_msg = NULL, ...)

Arguments

state

State to start from (for check_error)

...

S3 stuff

incorrect_msg

additional message that is appended to the automatically generated feedback message.

Details

If all SCTs for an exercise pass, before marking the submission as correct testwhat will automatically check whether the student submission generated an error, unless the exercise explicitly allows for errors. This means it is not needed to use check_error explicitly. However, in some cases, using check_error explicitly somewhere throughout your SCT execution can be helpful:

  • If you want to make sure people didn't write typos when writing a long function name.

  • If you want to first verify whether a function call actually runs,before checking whether the arguments were specified correctly.

  • More generally, if, because of the content, it's instrumental that the script runs without errors before doing any other verifications.

Examples

if (FALSE) { # Example student code: x <- 4 + "a" # SCT that explicitly checks for an error first ex() %>% check_error() ex() %>% check_object('x') %>% check_equal() # SCT that does not have to check for an error # testwhat will verify for an error implicitly ex() %>% check_object('x') %>% check_equal() }