test: Extract and run package tests

Description Usage Arguments Details Examples

Description

This function corresponds to an intentionally masks devtools::test() from the devtools package. This version is polymorphic depending on the number of arguments given.

Usage

1
2
3
4
5
test(..., pkg = switch(nargs(), ".", ..1), filter = switch(...length(),
  ..1, ..2))

extract_and_test_file(file = rstudioapi::getSourceEditorContext()$path,
  pkg = rstudioapi::getActiveProject())

Arguments

...

polymorphic arguments

pkg

The package to test.

filter

An optional filter to restrict the files to extract from and run tests for.

file

for test_file the exact file to extract and test from.

Details

When no arguments are provided all tests are extracted and run from the package corresponding to the active working directory. In other words test() is equivalent to test(pkg='.', filter=NULL)

If arguments are provided they may be named. If any argument is named all must be named, if not found the two key parameters will be taken to be

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
## Not run: 
# Extract and run all tests for the package in the
# current working directory.
test()

# One argument form
# extract and test class files for the
# package in the current working directory.
test("^Class-")

# Two argument form
# Extract files matching "Class" in the filename
# for the package located at "inst/textExtractionTest"
test("inst/testExtractionTest", "Class")


## End(Not run)

testextra documentation built on Dec. 18, 2019, 9:38 a.m.