It runs tests from specifications in .feature
files found in the path
.
Usage
test(
path = "tests/acceptance",
filter = NULL,
reporter = NULL,
env = NULL,
load_helpers = TRUE,
stop_on_failure = TRUE,
stop_on_warning = FALSE,
...
)
Arguments
- path
Path to directory containing tests.
- filter
If not NULL, only features with file names matching this regular expression will be executed. Matching is performed on the file name after it's stripped of ".feature".
- reporter
Reporter to use to summarise output. Can be supplied as a string (e.g. "summary") or as an R6 object (e.g.
SummaryReporter$new()
).See Reporter for more details and a list of built-in reporters.
- env
Environment in which to execute the tests. Expert use only.
- load_helpers
Source helper files before running the tests?
- stop_on_failure
If
TRUE
, throw an error if any tests fail.- stop_on_warning
If
TRUE
, throw an error if any tests generate warnings.- ...
Additional arguments passed to
grepl()
to control filtering.
Good Practices
Use a separate directory for your acceptance tests, e.g.
tests/acceptance
.It's not prohibited to use
tests/testthat
directory, but it's not recommended as those tests serve a different purpose and are usually run separately.Use
setup-*.R
files for callingstep()
,define_parameter_type()
andhook()
to leverage testthat loading mechanism.If your
step()
,define_parameter_type()
andhook()
are called from somewhere else, you are responsible for loading them.Read more about testthat special files in the testthat documentation.
Use
test-*.R
files to test the support code you might have implemented that is used to run Cucumber tests.Those tests won't be run when calling
test()
. To run those tests usetestthat::test_dir("tests/acceptance")
.