Skip to content

Testing if a function has been exported #1123

@hongooi73

Description

@hongooi73

Recently I pushed an update to one of my packages to CRAN. Before submitting, I did my usual routine of running devtools::test() and ensuring that all the tests passed. So far, no problem. However, after it was submitted (and approved), I happened to look at the package's NAMESPACE file, and realised that I had forgotten to run devtools:document() to update the list of exported functions. Because of this, a couple of functions that I had added to the package, and marked with @export directives, were not actually exported.

Is there a way of testing that functions that should be user-visible are, indeed, visible? By default testthat doesn't do this; from ?test_package:

For package tests, that environment that inherits from the package's namespace environment, so that tests can access internal functions and objects.

Hence the tests of my new functions all passed, as the testing code could see them despite not being visible to the end-user.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions