svSuiteData: Objects of class 'svSuiteData' contain results from running...

Description Usage Arguments Details Value Author(s) See Also Examples

Description

The 'svSuiteData' object contains results of all test run in one or more test suites. The checkxxx() functions and the runTest() method generate data (objects 'svTestData') contained in the default 'svSuiteData' named .Log and located in .GlobalEnv. It is then possible to display and report information it contains in various ways to analyze the results.

Usage

 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
is.svSuiteData(x)

## S3 method for class 'svSuiteData'
stats(object, ...)

metadata(object, ...)

## S3 method for class 'svSuiteData'
metadata(
  object,
  fields = c("R.version", "sessionInfo", "time", "description"),
  ...
)

## S3 method for class 'svSuiteData'
print(x, all = FALSE, file = "", append = FALSE, ...)

## S3 method for class 'svSuiteData'
summary(object, ...)

protocol(object, type = "text", file = "", append = FALSE, ...)

## Default S3 method:
protocol(object, type = "text", file = "", append = FALSE, ...)

## S3 method for class 'svSuiteData'
protocol(object, type = "text", file = "", append = FALSE, ...)

protocol_text(object, file = "", append = FALSE, ...)

## S3 method for class 'svSuiteData'
protocol_text(object, file = "", append = FALSE, ...)

protocol_junit(object, ...)

## S3 method for class 'svSuiteData'
protocol_junit(object, file = "", append = FALSE, ...)

Arguments

x

Any kind of object, or a 'svSuiteData' object in the case of print().

object

A 'svSuiteData' object.

...

Further arguments to pass to methods. Not used yet.

fields

Character vector. The name of all metadata items you want to extract for the object. The default value is an exhaustive list of all available metadata (i.e., defined by default) in the object, but you can add more: just add a corresponding attribute to your object.

all

Do we print concise report for all test, or only for the tests that fail or produce an error?

file

Character. The path to the file where to write the report. If file = "", the protocol report is output to the console.

append

Do we append to this file?

type

Character. The type of protocol report to create. For the moment, only type = "text" and type = "junit" are supported, but further types (HTML, LaTeX, Wiki, etc.) could be provided later.

Details

A 'svSuiteData' is, indeed, an environment. The results for the various tests runs are in non hidden (i.e., names not starting with a dot) objects that are of class 'svTestData' in this environment. Various other objects that control the execution of the test, their context, etc. are contained as hidden objects with name starting with a dot. Note that using an environment instead of a list for this object allows for a call by reference instead of a usual call by value in R, when passing this object to a function. This property is largely exploited in all svUnit functions to make sure results of test runs are centralized in the same log ('svSuiteData' object).

Value

is.svSuiteData() returns TRUE if the object is an 'svSuiteData'. The various methods serve to extract or print content in the object.

Author(s)

Philippe Grosjean; Mario Frasca for the junit protocol.

See Also

svSuite(), is.svTestData(), Log(), checkEquals()

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
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
clearLog()    # Clear any existing log

# Run some tests
checkTrue(1 < 2)
checkException(log("a"))
foo <- function(x, y = 2)
  return(x * y)
test(foo) <- function() {
  checkEqualsNumeric(4, foo(2))
  checkEqualsNumeric(6, foo(2, nonexisting))
  checkTrue(is.test(foo))
  warning("This is a warning")
  cat("Youhou from test!\n")  # Don't use, except for debugging!
  checkTrue(is.test(test(foo)))
  checkIdentical(attr(foo, "test"), test(foo))
  checkException(foo(2, nonexisting))
  #DEACTIVATED("My deactivation message")
  checkException(foo(2))  # This test fails
}
runTest(foo)

# Now inspect the log, which is a 'svSuiteData' object
is.svSuiteData(Log())
stats(Log())
metadata(Log())
Log()    # Print method
summary(Log())

## Not run: 
# To get a print of the test protocol on file, use:
protocol(Log(), type = "text", file = "RprofProtocol.out")
file.show("RprofProtocol.out")
unlink("RprofProtocol.out")

## End(Not run)

rm(foo)

## Not run: 
# Profiling of very simple test runs
library(utils)
createLog(description = "test profiling", deleteExisting = TRUE)
imax <- 3
jmax <- 100
l <- 50
Rprof()
for (i in 1:imax) {
  # Change the context for these tests
  .Log$..Test <- paste("Test", i, sep = "")
  .Log$..Tag <- paste("#", i, sep = "")
  res <- system.time({
    for (j in 1:jmax) checkTrue(i <= j, "My test")
  }, gcFirst = TRUE)[3]
  print(res)
  flush.console()
}
Rprof(NULL)
# Look at profile
summaryRprof()
unlink("Rprof.out")

# Look at the log
summary(Log())

## End(Not run)

svUnit documentation built on April 19, 2021, 9:06 a.m.