| Title: | A Framework for Unit Tests Generation |
|---|---|
| Description: | Generates 'testthat' compatible unit tests by tracing the execution of runnable R code, recording the arguments and return values of function calls, and turning them into reproducible test cases. |
| Authors: | Filip Krikava [aut, cre], Roman Tsegelskyi [aut], Petr Maj [aut], Filippo Ghibellini [ctb], Michal Vacha [ctb], Lei Zhao [ctb] |
| Maintainer: | Filip Krikava <[email protected]> |
| License: | GPL (>= 2) |
| Version: | 0.1.8 |
| Built: | 2026-07-16 23:53:36 UTC |
| Source: | https://github.com/PRL-PRG/genthat |
copy_traces(tracer)copy_traces(tracer)
Decorates all symbols form the given environment for which 'is.function' is 'TRUE'.
decorate_environment(env, decorator = get_decorator(), record_fun = substitute(genthat:::record_trace), exclude = character())decorate_environment(env, decorator = get_decorator(), record_fun = substitute(genthat:::record_trace), exclude = character())
envir |
an environment that shall be decorated or a character scalar that will be resolved using 'as.environment("package:....")'. In the latter case, the package will also be loaded in the case it has not been loaded yet. |
Given function will be decorated in their defining environment.
decorate_function(fun, name = substitute(fun), record_fun = substitute(genthat:::record_trace), decorator = get_decorator(), env = parent.frame())decorate_function(fun, name = substitute(fun), record_fun = substitute(genthat:::record_trace), decorator = get_decorator(), env = parent.frame())
fun |
the function that shall be decorated |
Downloads R package.
download_package(package, destdir, version = NULL, repos = getOption("repos"), type = "source", extract = TRUE, force = FALSE, quiet = TRUE, ...)download_package(package, destdir, version = NULL, repos = getOption("repos"), type = "source", extract = TRUE, force = FALSE, quiet = TRUE, ...)
Given a genthat trace it generates a corresponding test case
generate_test(trace, ...)generate_test(trace, ...)
trace |
trace value |
include_trace_dump |
whether to include raw trace at the beginning of the test the trace is formatted using 'str' function. |
given a trace, it generates a test and stores it in a file
generate_test_file(trace, output_dir, ...)generate_test_file(trace, output_dir, ...)
a data frame with the following pkg : chr fun : chr filename : chr (can be NA in which case error must be a chr) error : chr (can be NA in which case code must be NA) elapsed : numeric (can be NA)
genthat: A framework for unit tests generation
Returns the latest version of a given package that is available in the given repository.
get_package_version(package, repos = getOption("repos"), type = "source")get_package_version(package, repos = getOption("repos"), type = "source")
Sets the parent environment of all the functions defined in the given environment 'env' to 'parent'.
link_environments(env = parent.frame(), parent = parent.env(env), .fun_filter = is.local_closure)link_environments(env = parent.frame(), parent = parent.env(env), .fun_filter = is.local_closure)
env |
the environment in which to look for functions |
parent |
the environment to use as the parent environment of the functions |
Reverts decorated function back to their state they were before calling 'decorate_function'.
reset_function(fun, name = substitute(fun), decorator = get_decorator(), env = parent.frame())reset_function(fun, name = substitute(fun), decorator = get_decorator(), env = parent.frame())
Decorates all functions in a package and then generates test cases based on the code contained in the package examples, vignettes and tests.
trace_package(pkgs, files_to_run, output_dir = ".", decorator = "on.exit", tracer = "set", action = c("stats", "export", "generate"), working_dir = tempfile(pattern = "genthat-trace-"), quiet = TRUE, lib_paths = NULL)trace_package(pkgs, files_to_run, output_dir = ".", decorator = "on.exit", tracer = "set", action = c("stats", "export", "generate"), working_dir = tempfile(pattern = "genthat-trace-"), quiet = TRUE, lib_paths = NULL)
output_dir |
the name of the directory where to output traces or NULL if traces should not be saved |