Skip to contents

[Experimental]

Parse test files in a directory to extract test descriptions, file locations, line numbers, and associated GitHub issue numbers.

Usage

ExtractTestsFromFiles(
  strTestDir = "tests/testthat",
  envCall = rlang::caller_env()
)

Arguments

strTestDir

(length-1 character) Path to the directory containing test files. Defaults to "tests/testthat".

envCall

(environment) The environment to use for error reporting. Typically set to rlang::caller_env().

Value

A tibble::tibble() with columns:

  • Test: The desc field of the test from testthat::test_that().

  • File: Path to the file where the test is defined, relative to the package root.

  • LineStart: First line of the test.

  • LineEnd: Last line of the test.

  • Issues: List column containing integer vectors of associated GitHub issue numbers.

  • TaggedNoIssue: Logical indicating whether the test is tagged with #noissue.

Examples

if (FALSE) { # interactive()

  # Extract all tests
  ExtractTestsFromFiles()

  # Find tests with no linked issues
  ExtractTestsFromFiles() |>
    dplyr::filter(!lengths(Issues), !TaggedNoIssue)
}