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
name
The name of the test case
code
The code to be executed as part of the test case
points
The point value of the test case
hidden
Whether the test case is hidden
success_message
A message to show to students if the test passes
failure_message
A 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
name
The name of the test case
code
The code to be executed as part of the test case
points
The point value of the test case
hidden
Whether the test case is hidden
success_message
A message to show to students if the test passes
failure_message
A message to show to students if the test fails
Method run()
Run the test case against the provided environment.
Usage
TestCase$run(env)
Arguments
env
The 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
deep
Whether 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)