Skip to content

Instantly share code, notes, and snippets.

@brandmaier
Created June 6, 2024 12:56
Show Gist options
  • Save brandmaier/dc09e022b9ee39a99afd4d183ea96913 to your computer and use it in GitHub Desktop.
Save brandmaier/dc09e022b9ee39a99afd4d183ea96913 to your computer and use it in GitHub Desktop.
test whether developers forgot a browser() debug statement in their R package code
#'
#' This is a test using the `testthat` package for R
#'
#' @title Test whether developers forgot a browser() debug statement in their R package code
#'
#' @description
#' Test goal: Check all functions of the encompassing R package
#' for whether developers forgot a browser()-statement
#' while debugging.
#'
#' @author Andreas M. Brandmaier
#'
test_that("developers did not forget a browser() statement in the package code", {
all_func_names <- ls(getNamespace(testthat::testing_package()))
func_bodies <- sapply(all_func_names, body)
for (f in func_bodies) {
testthat::expect_false(any(grepl(pattern = "browser\\(\\)", x=f)))
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment