fcode <- '
f <- function(x) {
if (x)
f(!x)
else
FALSE
}'
options(covr.record_tests = TRUE)
cov <- code_coverage(fcode, "f(TRUE)")
# extract executed test code for the first test
tail(attr(cov, "tests")[[1L]], 1L)
# [[1]]
# f(TRUE)
# extract test itemization per trace
cov[[3]][c("srcref", "tests")]
# $srcref
# f(!x)
#
# $tests
# test depth i
# [1,] 1 2 4
# reconstruct the code path of a test by ordering test traces by [,"i"]
lapply(cov, `[[`, "tests")
# $`source.Ref2326138c55:4:6:4:10:6:10:4:4`
# test depth i
# [1,] 1 1 2
#
# $`source.Ref2326138c55:3:8:3:8:8:8:3:3`
# test depth i
# [1,] 1 1 1
# [2,] 1 2 3
#
# $`source.Ref2326138c55:6:6:6:10:6:10:6:6`
# test depth i
# [1,] 1 2 4
Run the code above in your browser using DataLab