testwhat (version 4.2.2)

test_correct: Test things. If it fails, test additional things.

Description

Test if a set of tests passes, and do additional, more precise tests if there were failures. The teacher should specify two code chunks;
  • check_code: specifies the code that checks on the (typically, final results of the) student's code. These tests are executed silently, without the reporter generating information for these.
  • diagnose_code: Set of tests that gets executed if the tests in check_code fail. These tests contain more detailed tests, to pinpoint the problem.

Usage

test_correct(check_code, diagnose_code)
check_correct(check_code, diagnose_code)

Arguments

check_code
Tests that are always run.
diagnose_code
Tests that are run, only if the tests in check_code fail.

Details

test_correct increases the flexibility for the student: if the tests in check_code pass, the results of the tests in diagnose_code are not considered. If you test for the end result in check_code, and only do more rigorous testing in diagnose_code, you can allow for multiple solutions to a challenge.

Examples

Run this code
## Not run: 
# # Example solution code:
# # x <- mean(1:3)
# 
# # Example SCT
# test_correct({
#  test_object("x")
# }, {
#  test_function("mean", "x")
# })
# 
# # Following submissions will all be accepted:
# x <- mean(1:3)
# x <- 2
# x <- mean(-1:5)
# ## End(Not run)

Run the code above in your browser using DataCamp Workspace