Package 'autotest'

Title: Automatic Package Testing
Description: Automatic testing of R packages by tracing function calls made in examples and tests, then systematically varying the inputs to check that functions respond sensibly.
Authors: Mark Padgham [aut, cre] (ORCID: <https://orcid.org/0000-0003-2172-5265>), Jouni Helske [ctb] (ORCID: <https://orcid.org/0000-0001-7130-793X>)
Maintainer: Mark Padgham <[email protected]>
License: GPL-3
Version: 0.1.0.034
Built: 2026-08-04 15:14:29 UTC
Source: https://github.com/ropensci-review-tools/autotest

Help Index


autotest_obj class definition

Description

This function exists only to provide the class definitions for test objects, and is not intended to be called directly.

Usage

autotest_obj(
  package = NA_character_,
  package_loc = NULL,
  test_name = NA_character_,
  fn_name = NA_character_,
  parameters = list(),
  parameter_types = NA_character_,
  class = NULL,
  classes = NULL,
  env = new.env(),
  test = FALSE,
  quiet = FALSE
)

Arguments

package

Name of package for which object is to be constructed.

package_loc

Location of package on local system (for source packages only)

test_name

Name of test (use autotest_types to get all test names).

fn_name

Name of function to be tested.

parameters

Names of all parameters for that function.

parameter_types

Types of input parameters.

class

Class of an individual parameter.

classes

Classes of all parameters.

env

Environment in which tests are to be run.

test

If FALSE, return only descriptions of tests which would be run with test = TRUE, without actually running them.

quiet

If FALSE, issue progress and other messages during testing of object.


autotest_package

Description

Automatically test an entire package by tracing calls made in its documented examples (and, for local source packages, its test suite) with typetracer, then testing each traced function call in turn.

Usage

autotest_package(
  package = ".",
  functions = NULL,
  exclude = NULL,
  test = FALSE,
  test_data = NULL,
  progress = c("bar", "tests", "none")
)

Arguments

package

Name of package, as either

  1. Path to local package source

  2. Name of installed package

  3. Full path to location of installed package if not on .libPaths, or

  4. Default which presumes current directory is within package to be tested.

functions

Optional character vector containing names of functions of nominated package to be included in 'autotesting'.

exclude

Optional character vector containing names of any functions of nominated package to be excluded from 'autotesting'.

test

If FALSE, return only descriptions of tests which would be run with test = TRUE, without actually running them.

test_data

Result returned from calling either autotest_types or autotest_package with test = FALSE that contains a list of all tests which would be conducted. These tests have an additional flag, test, which defaults to TRUE. Setting any tests to FALSE will avoid running them when test = TRUE.

progress

Style of progress display while testing functions, one of:

  • "bar" (default) A cli progress bar. Automatically falls back to "none" when called from within a knitr document, to avoid literal ANSI escape sequences leaking into the rendered output.

  • "tests" One line per function tested, showing ⁠[i / n]⁠.

  • "none" No progress display at all.

Value

An autotest_package object which is derived from a tibble tbl_df object. This has one row for each test, and the following eight columns:

  1. type The type of result, either "dummy" for test = FALSE, or one of "error", "warning", "diagnostic", or "message".

  2. test_name Name of each test

  3. fn_name Name of function being tested

  4. parameter Name of parameter being tested

  5. parameter_type Expected type of parameter as identified by autotest.

  6. operation Description of the test

  7. content For test = FALSE, the expected behaviour of the test; for test = TRUE, the observed discrepancy with that expected behaviour

  8. test If FALSE (default), list all tests without implementing them, otherwise implement all tests.

Some columns may contain NA values, as explained in the Note.

Note

Some columns may contain NA values, including:

  • parameer and parameter_type, for tests applied to entire functions, such as tests of return values.

  • test_name for warnings or errors generated through "normal" function calls generated directly from example code, in which case type will be "warning" or "error", and content will contain the content of the corresponding message.

See Also

Other main_functions: autotest_types()


autotest_types

Description

List all types of 'autotests' currently implemented.

Usage

autotest_types(notest = NULL)

Arguments

notest

Character string of names of tests which should be switched off by setting the test column to FALSE. Run this function first without this parameter to get all names, then re-run with this parameter switch specified tests off.

Value

An autotest object with each row listing one unique type of test which can be applied to every parameter (of the appropriate class) of each function.

See Also

Other main_functions: autotest_package()


expect_autotest_no_err

Description

Expect autotest_package() to be clear of errors

Usage

expect_autotest_no_err(object)

Arguments

object

An autotest object to be tested

Value

(invisibly) The same object

See Also

Other expectations: expect_autotest_no_testdata(), expect_autotest_no_warn(), expect_autotest_notes(), expect_autotest_testdata()


expect_autotest_no_testdata

Description

Expect autotest_package() to be clear of errors with no tests switched off

Usage

expect_autotest_no_testdata(object = NULL)

Arguments

object

Not used here, but required for testthat expectations

Value

(invisibly) The autotest object

See Also

Other expectations: expect_autotest_no_err(), expect_autotest_no_warn(), expect_autotest_notes(), expect_autotest_testdata()


expect_autotest_no_warn

Description

Expect autotest_package() to be clear of warnings

Usage

expect_autotest_no_warn(object)

Arguments

object

An autotest object to be tested

Value

(invisibly) The same object

See Also

Other expectations: expect_autotest_no_err(), expect_autotest_no_testdata(), expect_autotest_notes(), expect_autotest_testdata()


expect_autotest_notes

Description

Expect test_data param of autotest_package to have additional note column explaining why tests have been switched off.

Usage

expect_autotest_notes(object)

Arguments

object

An autotest object to be tested

See Also

Other expectations: expect_autotest_no_err(), expect_autotest_no_testdata(), expect_autotest_no_warn(), expect_autotest_testdata()


expect_autotest_testdata

Description

Expect autotest_package() to be clear of errors with some tests switched off, and to have note column explaining why those tests are not run.

Usage

expect_autotest_testdata(object)

Arguments

object

An autotest_package object with a test column flagging tests which are not to be run on the local package.

Value

(invisibly) The autotest object

See Also

Other expectations: expect_autotest_no_err(), expect_autotest_no_testdata(), expect_autotest_no_warn(), expect_autotest_notes()