Created
June 6, 2024 12:56
-
-
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 file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#' | |
#' 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