test_execution: Tests Silent Execution of an Function

Description Usage Arguments Value Author(s) See Also Examples

View source: R/utils.test.R

Description

Tests Silent Execution of an Function

Usage

1
test_execution(what, args, xmlTestSpec = NULL, ...)

Arguments

what, args

Parameters for execution of the test function (see do.call).

xmlTestSpec

(XMLNode) The XML definition of type 'RTestTest_variable'.

...

Additional parameters passed to do.call.

Value

ANY result of test functin

Author(s)

Matthias Pfeifer matthias.pfeifer@roche.com

See Also

do.call

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
value <- test_execution(
      "sum",
      list(x=2,y=3),
      xmlTestSpec=XML::xmlNode(
          name="execution",
          attrs=list('execution-type'="silent"))
)
stopifnot(value==5)

# Create a function that always produces warnings

sum_test <- function(...){
  warning("test")
  sum(...)
}

# Let this function run and crash, if it crashes check if the error contains "produced warnings"

tryCatch(
test_execution(
   "sum_test",
    list(x=2,y=3),
   xmlTestSpec=XML::xmlNode(name="execution",attrs=list("execution-type"="silent"))
 ),error=function(e){
    stopifnot(grepl("produced warnings",e))
 })

RTest documentation built on Dec. 4, 2019, 5:07 p.m.