Class for unit testing a mighty component with code coverage tracking. Runs component code in an isolated R session and tracks which lines are executed during testing.
Details
Always use get_test_component() to create instances for testing. The test
workflow is:
Create test component with
get_test_component()Assign input data with
$assign()Execute and track coverage with
$eval()Retrieve results with
$get()Test results with
expect_*()functions from{testthat}
Coverage is automatically checked at test teardown via $check_coverage().
Super classes
mighty.component::mighty_component -> mighty.component::mighty_component_rendered -> mighty_component_test
Active bindings
percent_coveragenumericPercentage of lines covered (0-100).line_coveragedata.framewith columnslineandvalueshowing execution count per line.
Methods
Method new()
Create test component from rendered template.
Usage
mighty_component_test$new(template, id)Method assign()
Assign a variable in the isolated test session.
Method get()
Retrieve a variable from the isolated test session.
Method ls()
List all objects in the isolated test session.
Method eval()
Execute the component code and update coverage tracking.
Method check_coverage()
Check that all lines in the component were executed at least once. Throws an error if any lines have zero coverage.
