library(revealgenomics)
#### Run testthat tests ####
testres = testthat::test_dir(
path = "tests/testthat/",
reporter = "summary")
#### Inspect results ####
L1 = lapply(
testres,
function(elem) sapply(elem$results, function(elem_result) class(elem_result)[1]))
names(L1) = sapply(testres, function(elem) paste0(elem$context, " / ", elem$test))
message("======+++=====================================\n")
message("testhat results\n")
message("======+++=====================================\n")
summary_testthat = table(unlist(L1))
names(summary_testthat) = gsub("expectation_", "", names(summary_testthat))
print(summary_testthat)
#### Report log ####
message("======+++=====================================\n")
message("Entire testthat log is here\n")
message("======+++=====================================\n")
print(testres)
#### Fail on errors ####
L1x = unlist(L1)
failures = L1x[which(!(L1x %in%
c('expectation_success',
'expectation_warning',
'expectation_skip')))]
if (length(failures) != 0) {
message("======+++=====================================\n")
message("The following testthat failures were encountered\n")
message("======+++=====================================\n")
print(failures)
stop("testthat tests did not pass")
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.