R/svTestData.R
svTestData.Rd
The 'svTestData' contains results of test run. The checkxxx()
functions and
the runTest()
method generate one such object which is located in the
.Log
object in .GlobalEnv
. It is then possible to display and report
information it contains in various ways to analyze the results.
is.svTestData(x)
stats(object, ...)
# S3 method for svTestData
stats(object, ...)
# S3 method for svTestData
print(x, all = FALSE, header = TRUE, file = "", append = FALSE, ...)
# S3 method for svTestData
summary(object, header = TRUE, file = "", append = FALSE, ...)
# S3 method for svTestData
protocol_junit(object, ...)
Any kind of object, or a 'svTestData' object in the case of
print()
.
A 'svTestData' object.
Further arguments to pass to methods. Not used yet.
Do we print concise report for all test, or only for the tests that fail or produce an error?
Do we print a header or not?
Character. The path to the file where to write the report. If
file = ""
, the report is output to the console.
Do we append to this file?
is.svTestData()
returns TRUE
if the object is an 'svTestData'. The
various methods serve to extract or print content in the object.
foo <- function(x, y = 2)
return(x * y)
is.test(foo) # No
#> [1] FALSE
# Create test cases for this function
test(foo) <- function() {
checkEqualsNumeric(4, foo(2))
checkEqualsNumeric(5, foo(2, 3))
checkEqualsNumeric(5, foo(nonexists))
}
# Generate a 'svTestData' object by running the test
obj <- runTest(foo) # Equivalent to runTest(test(foo)), but shorter
#> * : checkEqualsNumeric(5, foo(2, 3)) run in less than 0.001 sec ... **FAILS**
#> Mean relative difference: 0.2
#> num 6
#> * : checkEqualsNumeric(5, foo(nonexists)) run in less than 0.001 sec ... **ERROR**
#> Error in foo(nonexists) : object 'nonexists' not found
obj
#>
#> == test(foo) run in less than 0.1 sec: **ERROR**
#>
#> //Pass: 1 Fail: 1 Errors: 1//
#>
#> * : checkEqualsNumeric(5, foo(2, 3)) run in less than 0.001 sec ... **FAILS**
#> Mean relative difference: 0.2
#> num 6
#>
#> * : checkEqualsNumeric(5, foo(nonexists)) run in less than 0.001 sec ... **ERROR**
#> Error in foo(nonexists) : object 'nonexists' not found
summary(obj)
#>
#> == test(foo) run in less than 0.1 sec: **ERROR**
#>
#> //Pass: 1 Fail: 1 Errors: 1//
#>
#> === Failures
#> [2] : checkEqualsNumeric(5, foo(2, 3))
#>
#> === Errors
#> [3] : checkEqualsNumeric(5, foo(nonexists))
#>
stats(obj)
#> $kind
#> OK **FAILS** **ERROR** DEACTIVATED
#> 1 1 1 0
#>
#> $timing
#> timing
#> 0
#>
is.svTestData(obj)
#> [1] TRUE
rm(foo, obj)