| TestCase {ottr} | R Documentation |
An R6 class representing a test case
Description
A test case for Ottr. Contains configurations and code to be executed for the test.
Public fields
nameThe name of the test case
codeThe code to be executed as part of the test case
pointsThe point value of the test case
hiddenWhether the test case is hidden
success_messageA message to show to students if the test passes
failure_messageA message to show to students if the test fails
Methods
Public methods
Method new()
Create a test case.
Usage
TestCase$new( name, code, points = 1, hidden = FALSE, success_message = NA, failure_message = NA )
Arguments
nameThe name of the test case
codeThe code to be executed as part of the test case
pointsThe point value of the test case
hiddenWhether the test case is hidden
success_messageA message to show to students if the test passes
failure_messageA message to show to students if the test fails
Method run()
Run the test case against the provided environment.
Usage
TestCase$run(env)
Arguments
envThe environment to run the test case in
Method to_list()
Convert this test case to a JSON-compatible list with all of its fields.
Usage
TestCase$to_list()
Returns
The list representation of this test case
Method clone()
The objects of this class are cloneable with this method.
Usage
TestCase$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
Examples
tc = TestCase$new("q1", {
testthat::assert_true(q1.ans)
})
env = new.env()
env$q1.ans = TRUE
tc$run(env)