This package models the common Unit Test framework for R and provides functionality to track results of test case execution and generate a summary report. It also provides tools for code inspection and thus for test case coverage analysis. The design is inspired by the popular JUnit unit test framework.
runTestSuite is the central function of the RUnit package. Given one or more test suites it identifies and sources specified test code files one after another and executes all specified test functions defined therein. This is done sequentially for suites, test code files and test functions. During the execution information about the test function calls including the possible occurrence of failures or errors is recorded and returned at the end of the test run. The return object can then be used to create a test protocol of various formats.
(Package: RUnit) :
Tracking the results of the inspect process.
The current implementation uses the 'closure trick' to hide all details from the user and only allows to retrieve the results of the code inspection. tracker is used to create a new environment to manage and store the results of the tracking process. The inspect function requires such an environment with the name "track" (currently mandatory). The tracker records how often each and every function was called by inspect and summarizes the results of all calls. tracker$init initializes the tracker environment. tracker$getTrackInfo returns a list with the tracked results of the inspection process.
(Package: RUnit) :
Track the executed code lines of a function or method.
inspect examines and modifies the source code of a function or method. After the modification of the source code, the modified function will be executed and the result of the tracking process will be stored. To store the information a tracker environment with the name track must exist. Note, that not all R code constructs can be handled at the current state. In some cases it is not possible to track a specific code line. Therefore, clearly structured code with consequent use of opening and closing braces to indicate conditional expressions can prevent these parser problems.