Tests imported Test Cases

# S4 method for RTestCollection
exec(object, test.TCs = NULL,
  test.for = NULL, out.fPath = NULL, open = TRUE, ...)

Arguments

object

(object) The RTestCollection-class object.

test.TCs

(character) Vector with the TCs to be executed or NULL if all all TCs of the collection should be tested.

test.for

(vector(character)) Specification for which elements to test, NULL for test all elements

out.fPath

(character) Path to output file.

open

(logical) Should the generated file be opened (TRUE) or not (FALSE) after report generation.

...

(logical) Additional parameters passed to function writeExecSummary.html.

See also

RTestCollection-class

Examples

testCollection <- new("RTestCollection", project.name = "RTest Vignette", project.details = "Example test exectuion", tester = "Example tester", test.start = format(Sys.time(), "%Y-%m-%d %H:%M:%S")) TCDir <- list.dirs(find.package("RTest"),recursive = TRUE) %>% grep(pattern = "xml-templates", value = TRUE) message("Test Adapter being used is defined in Function")
#> Test Adapter being used is defined in Function
message("test.RTest.test_returnValue_data.frame_cellbycell")
#> test.RTest.test_returnValue_data.frame_cellbycell
testCollection <- importTCsFromDir(testCollection, xml.dPath = TCDir[1],f.pattern = "RTest_TC-01.xml")
#> 1 files found in input directory: #> [1] "RTest_TC-01.xml" #> #> Import TC file '/tmp/RtmpSMomZh/temp_libpath6c0625f3fa09/RTest/xml-templates/RTest_TC-01.xml' #> #> Create new TC using adapter definition 'RTestCase'.Test Case #> Object of class ' RTestCase ' #> @ID : RTest_TC-01 #> @tc.type : RTestCase #> @synopsis : #> $version : 01 #> $author : Matthias Pfeifer #> $short-description : RTest Template TC #> $description : Extended Description of the test case allowing also <some><special>/characters #> $label : #> $creation-date : 2016-01-25 #> $change-history : #> 2016-01-25 , Matthias Pfeifer : #> Initial Version #> #> @xml.fPath : /tmp/RtmpSMomZh/temp_libpath6c0625f3fa09/RTest/xml-templates/RTest_TC-01.xml #> @xml.root : XMLNode #> #> @input.data : #> test01 : 'data.frame': 2 obs. of 2 variables: #> $ x: num 1 1 #> $ y: num 2 2 #> #> @test.for : NA #> @test.result : NA #> #> @tests : #> RTest : List of 1 #> $ :List of 1 #> ..$ funct_01:List of 1 #> .. ..$ :List of 16 #> .. .. ..$ pkg : chr "RTest" #> .. .. ..$ pgk-iter : num 1 #> .. .. ..$ func : chr "funct_01" #> .. .. ..$ func-iter : num 1 #> .. .. ..$ test-code : chr "RTest::funct_01" #> .. .. ..$ test-adapter: chr "RTestCase" #> .. .. ..$ test-func : chr "test.RTest.funct_01" #> .. .. ..$ pkg-desc : chr "First test for Pkg_1" #> .. .. ..$ func-desc : chr "First test of funct_01" #> .. .. ..$ xpath : chr "//RTestCase/tests/RTest[1]/funct_01[1]" #> .. .. ..$ reporter : logi NA #> .. .. ..$ result : logi NA #> .. .. ..$ cache : logi NA #> .. .. ..$ execresid : logi NA #> .. .. ..$ specid : chr "" #> .. .. ..$ riskid : chr "" #> #>
testCollection <- exec(testCollection)
#> Execute following test cases: #> [1] "RTest_TC-01" #> #> ##### TEST CASE 'RTest_TC-01' #> #> Test for: 'RTest' #> #> Run test(s) for 'RTest' #> Test 'RTest::funct_01' ... data.frame: 2 x 3 ...
#> Warning: Calling 'structure(NULL, *)' is deprecated, as NULL cannot have attributes. #> Consider 'structure(list(), *)' instead.
#> success #>
outf <- tempfile(fileext=".html") writeExecSummary.html(testCollection, out.fPath = outf,open = FALSE)
#> Write HTML summary for following test cases: #> [1] "RTest_TC-01" #> #> Write details for 'RTest::funct_01' #> Execute function silently. (test_fun) #> 0% #> Check return value (data.frame). #> 0% #> #> HTML summary written to file '/tmp/Rtmpq5S1Sv/file6c3d3f763ea2.html'. #>
stopifnot(any(grepl("passed",readLines(outf))))