rpac_test_template: Create a template for a test in testthat style and add...

View source: R/rpac_test_template.R

rpac_add_testR Documentation

Create a template for a test in testthat style and add boilerplate code

Description

rpac_test_template() creates a file with boilerplate code for running tests with testthat. rpac_add_test() appends a blurb for tests for a given function.

Usage

rpac_add_test(test_name = NULL, function_name = NULL,
  path = "tests/testthat/", append = TRUE, open = TRUE)

rpac_test_template(test_name = NULL, pkg_name = NULL,
  path = "tests/testthat")

Arguments

test_name

Name for test, inserted into 'test- name in rpac_test_template(). rpac_add_test() expects the same string to find the file and append to it.

function_name

Name of function that test will be used for.

path

Pass a path as string. Default is to place files for tests in the directory './tests/testthat/'.

append

Append text to an existing file. Default is TRUE.

open

Open the project in RStudio on creation. Default is TRUE.

pkg_name

package name as string.

Note

Run this for each file needed to create a test-testname.R file with a blurb. Files must be within tests/testthat/ or inst/tests and start with 'test' and end in '.R' for testthat to pick them up. There are many types of tests, see testthat::expect_.

Author(s)

Antonio J. Berlanga-Taylor <https://github.com/AntonioJBT/Rpacker>

See Also

<http://r-pkgs.had.co.nz/tests.html>, <http://testthat.r-lib.org/articles/custom-expectation.html>, use_test.

Examples


## Not run: 
rpac_test_template(test_name = 'rpack_test_template',
                   pkg_name = 'rpack',
                   path = 'tests/testthat/'
                   )

rpac_add_test(test_name = 'rpack_test_template',
              function_name = 'function_to_test',
              path = 'tests/testthat',
              append = TRUE,
              open = TRUE
              )

## End(Not run)


AntonioJBT/Rpacker documentation built on May 1, 2024, 1:06 a.m.