Description Usage Arguments Value Author(s) Examples
Constructor for RTestCase
1 2 3 |
ID |
( |
tc.type |
( |
synopsis |
( |
xml.fPath |
( |
xml.root |
( |
input.data |
( |
tests |
( |
test.for |
( |
test.result |
( |
(.Object) RTestCase-class Object
Matthias Pfeifer matthias.pfeifer@roche.com
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 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 | library(RTest)
xml.root <- XML::newXMLNode("func01")
RTest::xmlFromList(xml.root,
list(
params=list(mult=list(attributes=c(value="1",type="numeric"))),
testspec=list(
execution=list(attributes=c("execution-type"="silent")),
"return-value"=list(attributes=c(
"compare-type"="equal",
"diff-type"="absolute",
"tolerance"=0.001
))
)
)
)
# Add the reference result to the params and testspec and read it in again
xml.root <- XML::xmlRoot(XML::xmlTreeParse(
paste0("<root>",
capture_output(print(xml.root[[1]])),
capture_output(print(xml.root[[2]])),
paste(xmlWriteData_data.frame(
"reference",
data=data.frame(x=c(1,1),y=c(2,2),sum=c(3,3)),
printXML=FALSE)
,collapse="\n"),"</root>")
))
# Define what to test in the first test
# Please check the function test.RTest.funct_01 to see
# how it tests the code of the function ("test_fun")
tests <- new.env()
testEntry <- list(
"pkg" = "RTest", # test description
"pgk-iter" = "1",
"func" = "funct_01",
"func-iter" = "1",
"test-code" = "RTest::test_fun",
"test-adapter" = "RTestCase",
"test-func" = "test.RTest.funct_01",
"pkg-desc" = "no package desc",
"func-desc" = "Simple add func",
"xpath" = "/root",
"reporter" = NA, # field for testthat reporter
"result" = NA, # field for test result (failed/success)
"cache" = NA, # field for caching test results
"execresid" = NA, # field for test execution result id
"specid" = "0", # field for test function id
"riskid" = "0" # field for test function risk id
)
# Assign test entry to test environment
# pkg-name pkg-iter func-name func-iter
tests[["RTest"]][["1"]][["funct_01"]][["1"]] <- testEntry
# Create a TestCase Object
object <- RTestCase(
ID="1",
tc.type="RTestCase",
synopsis= list(version="v1",author="Sebastian Wolf"),
xml.fPath="",
xml.root=xml.root,
input.data=list("one"=
data.frame(x=c(1,1),y=c(2,2))
),
tests=tests,
test.for="RTest",
test.result=NA
)
# Run the test
object <- test(object,test.for="RTest")
stopifnot(object@test.result=="success")
# Run a failing test
object@input.data <- list("one"=
data.frame(x=c(1,2),y=c(2,1))
)
object <- test(object,test.for="RTest")
stopifnot(object@test.result=="failed")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.