Skip to contents

Compare cases by their explicit IDs. A case is added or removed when its ID occurs in only one plan, moved when its suite changes, and changed when its description or generated test code changes. Changes to fixture and required are also compared when the column occurs in both plans. Other columns are ignored.

Usage

compare_test_plans(before, after)

Arguments

before, after

Data frames containing id, suite, source, path, description, and code character columns without missing values. IDs must be nonempty and unique within each plan. Suites must be tests or longtests. The code column contains the generated setup and test body. Optional fixture and required columns may contain atomic values or lists, with one value per case. These values are compared with identical().

Value

A data frame with id, status, before_suite, after_suite, before_source, after_source, before_path, and after_path columns. Missing sides of additions and removals contain NA. The fields list column contains the affected field names: suite for moves, changed content or metadata fields for changes, and an empty character vector for additions and removals. Rows are sorted by ID, with a move before a content change for the same ID. Identical plans return zero rows.

Details

A case that changes both suite and content produces two rows, one for each status. Source and output paths provide context but do not determine case identity or content changes. Moving a case to another source file alone therefore produces no row. An ID rename appears as a removal and an addition. Neither plan is modified, and no tests are run.

Examples

before <- data.frame(
  id = "alignment/memory", suite = "tests", source = "R/select.R",
  path = "tests/testthat/test-roxytest-tests-select.R",
  description = "Sample identifiers stay aligned",
  code = "expect_identical(actual, expected)"
)
after <- before
after$suite <- "longtests"
after$path <- "longtests/testthat/test-biocroxytest-longtests-select.R"
after$code <- "expect_identical(actual, expected); expect_s4_class(result, 'S4')"
compare_test_plans(before, after)
#>                 id  status before_suite after_suite before_source after_source
#> 1 alignment/memory   moved        tests   longtests    R/select.R   R/select.R
#> 2 alignment/memory changed        tests   longtests    R/select.R   R/select.R
#>                                   before_path
#> 1 tests/testthat/test-roxytest-tests-select.R
#> 2 tests/testthat/test-roxytest-tests-select.R
#>                                                after_path fields
#> 1 longtests/testthat/test-biocroxytest-longtests-select.R  suite
#> 2 longtests/testthat/test-biocroxytest-longtests-select.R   code