-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTestInDirScriptTest.R
89 lines (88 loc) · 2.59 KB
/
TestInDirScriptTest.R
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
82
83
84
85
86
87
88
89
#!/usr/bin/Rscript
# The purpose of InDirScriptTest is to serve as a parent for
# test classes that inherit from it.
# Therefore we create such classes
require(R6Unit)
TestInDirScriptTest<-R6Class("TestInDirScriptTest",
inherit=TestCase,
public=list(
#------------------------
test.writeInDir=function(){
# create a small TestClass that tests some IO code
IoScriptTest<-R6Class("IoScriptTest",
inherit=InDirScriptTest,
public=list(
test.write_and_read=function(){
content="swimming"
fn="myPersonalTestFile"
write(content,file=fn)
print("hi there")
res<-readLines(fn)[[1]]
stopifnot(identical(content,res))
}
)
)
iot<-IoScriptTest$new("test.write_and_read")
sr<-iot$get_SingleTestResult()
self$assertFalse(sr$has_failed())
}
#,
##------------------------
#test.workingSetup=function(){
# # check if thw setUp function interpretes
# # filepaths now locally
# IoScriptTest1<-R6Class("IoScriptTest1",
# inherit=InDirScriptTest,
# private=list(
# content="written by setUp",
# #------------------------
# fn="myPersonalTestFile"
# #------------------------
# ),
# public=list(
# setUp=function(){
# print("######## everything is fine #############")
# write(private$content,file=private$fn)
# }
# ,
# #------------------------
# test.somethingThatNeverFails=function(){
# self$assertTrue(TRUE)
# res<-readLines(private$fn)[[1]]
# self$assertEqual(private$content,res)
# }
# )
# )
# iot<-IoScriptTest1$new("test.somethingThatNeverFails")
# sr<-iot$get_SingleTestResult()
# self$assertEqual(sr$has_error(),FALSE)
#}
#,
##------------------------
#test.failingSetup=function(){
# IoScriptTest2<-R6Class("IoScriptTest2",
# inherit=InDirScriptTest,
# public=list(
# setUp=function(){
# stop("an error in setup")
# }
# ,
# ####
# test.somethingThatNeverFails=function(){
# self$assertTrue(TRUE)
# }
# )
# )
# iot<-IoScriptTest2$new("test.somethingThatNeverFails")
# sr<-iot$get_SingleTestResult()
# self$assertEqual(sr$has_error(),TRUE)
#}
)
)
# check if the file is sourced or directly executed
if(is.null(sys.calls()[[sys.nframe()-1]])){
s<-get_suite(TestInDirScriptTest)
#s$parallel <- 1
tr<-s$run()
cat(tr$summary())
}