This function parses a single testthat test file and extracts a structured representation of the expectations it contains. It identifies top‑level test blocks (e.g., `test_that()`, `describe()`, `tar_test()`) and any nested expectation blocks (e.g., `it()`). The result maps expectation location, context, and source line ranges for downstream analysis.
map_test(path)A `data.frame` in which each row corresponds to an expectation identified in the test file. Typical columns include:
Context or test block label derived from the test file.
The expectation type (e.g., `expect_equal`).
Numeric vector giving the range of lines associated with the expectation.
Test label (combined description and nested block label, if applicable).
This structured output is used internally by STF test‑mapping functions (e.g., `map_tests_stf()`) for coverage analysis, skip mapping, and test reporting.
Character. Path to a single test file (typically named `test-*.R`).
The function uses `utils::getParseData()` to inspect parse information from the test file and constructs a hierarchical mapping of:
test block context (e.g., `describe()`, `test_that()`)
test labels or sub‑contexts (e.g., `it()` blocks)
expectation type
source line ranges associated with each expectation
If the file does not contain any parseable test blocks or expectations, `NULL` is returned.
Other stf_utility:
create_coverage_skip_stf(),
map_tests_stf(),
nest_test(),
run_covr_skip_stf()