Skip to contents

Extract unit test srcrefs from a coverage object. A test name will be derived from the test source code, preferrably from a written annotation, but otherwise falling back to using a code snippet. srcrefs are unique for each expression executed within a testing suite.

Usage

test_srcrefs_df(x)

Arguments

x

A package_coverage coverage object, from which the name of the package used is extracted.

Value

A data.frame of test srcrefs extracted from a coverage object. Contains one record for each srcref with variables:

name

A character test description. For testthat tests, the desc parameter will be used, otherwise a snippet of code will be used for the test name

srcref

A srcref object describing the location of the test

test_type

A character indicating the structure of the test. One of "testthat", "call" or NULL

See also

srcrefs test_trace_mapping

Other srcrefs_df: pkg_srcrefs_df(), trace_srcrefs_df()

Examples

options(covr.record_tests = TRUE)
pkg_path <- system.file("examplepkg", package = "covtracer")
cov <- covr::package_coverage(pkg_path)
test_srcrefs_df(cov)
#>                                                         name
#> 1                       S4 Generic Call: show(<myS4Example>)
#> 2               Calling a deeply nested series of functions.
#> 3             Calling a function halfway through call stack.
#> 4                                               symbol: desc
#> 5                                               symbol: desc
#> 6                                               symbol: desc
#> 7                                               symbol: desc
#> 8                                               symbol: desc
#> 9                                               symbol: desc
#> 10                                              symbol: desc
#> 11                                              symbol: desc
#> 12                                              symbol: desc
#> 13                                              symbol: desc
#> 14                        hypotenuse is calculated correctly
#> 15 hypotenuse is calculated correctly; with negative lengths
#> 16        Example R6 Accumulator class constructor is traced
#> 17           Example R6 Accumulator class methods are traced
#> 18           Example R6 Accumulator class methods are traced
#> 19         Example R6 Person class public methods are traced
#> 20         Example R6 Person class public methods are traced
#> 21  Example R6 Rando class active field functions are traced
#> 22              s3_example_func works using default dispatch
#> 23                 s3_example_func works using list dispatch
#> 24                              S4Example names method works
#> 25                  S4Example increment generic method works
#>                             srcref     type
#> 1                             <NA>     call
#> 2    test-complex-calls.R:2:3:2:50 testthat
#> 3    test-complex-calls.R:6:3:6:54 testthat
#> 4  test-complex-calls.R:15:7:15:54 testthat
#> 5  test-complex-calls.R:15:7:15:54 testthat
#> 6  test-complex-calls.R:15:7:15:54 testthat
#> 7  test-complex-calls.R:15:7:15:54 testthat
#> 8  test-complex-calls.R:15:7:15:54 testthat
#> 9  test-complex-calls.R:15:7:15:54 testthat
#> 10 test-complex-calls.R:15:7:15:54 testthat
#> 11 test-complex-calls.R:15:7:15:54 testthat
#> 12 test-complex-calls.R:15:7:15:54 testthat
#> 13 test-complex-calls.R:15:7:15:54 testthat
#> 14      test-hypotenuse.R:2:3:2:35 testthat
#> 15      test-hypotenuse.R:5:5:5:39 testthat
#> 16      test-r6-example.R:2:3:2:43 testthat
#> 17      test-r6-example.R:7:3:7:43 testthat
#> 18      test-r6-example.R:8:3:8:36 testthat
#> 19    test-r6-example.R:12:3:12:40 testthat
#> 20    test-r6-example.R:13:3:13:26 testthat
#> 21    test-r6-example.R:18:3:18:38 testthat
#> 22      test-s3-example.R:2:3:2:46 testthat
#> 23      test-s3-example.R:6:3:6:54 testthat
#> 24      test-s4-example.R:3:3:3:40 testthat
#> 25      test-s4-example.R:7:3:7:31 testthat