Setup environment
Load the necessary package and set CRAN repository.
library(risk.assessr)
options(repos = "http://cran.us.r-project.org")Run traceability matrices and risk assessment
Analyze the stringr package to create a traceability matrix.
There are a number of ways to do this:
Firstly, if you just want a traceability matrix with no test coverage, you can run the following code:
stringr_tm_no_test <- risk.assessr::generate_traceability_matrix("stringr", version = "1.5.1" )
str(stringr_tm_no_test$tm)Secondly, if you want a traceability matrix with test coverage, you can run the following code:
stringr_tm_test <- risk.assessr::generate_traceability_matrix("stringr", version = "1.5.1", execute_coverage = TRUE)
str(stringr_tm_test$tm)If you want a full analysis of the package containing a traceability matrix and ither risk data, you can run the following:
stringr <- risk.assessr::assess_pkg_r_package("stringr", version = "1.5.1" )This returns a structured list with traceability and function risk information.
Structure of traceability matrices
str(stringr$tm_list)Get coverage summary by risk level
See how functions are mapped to risk and test coverage. This shows all the exported functions.
stringr$tm_list$tmThis shows functions categorized as high, medium, or low risk test coverage.
stringr$tm_list$coverage