| writeJUnit {tinytest2JUnit} | R Documentation |
Write the results of a tinytests-object into JUnit xml report.
Description
Write the tinytests-object to a JUnit XML reporting file. If a tinytests2JUnit is provided
(returned by runTestDir()) more info will get reported.
Usage
writeJUnit(tinytests, file = stdout(), overwrite = TRUE)
Arguments
tinytests |
|
file |
|
overwrite |
|
Value
invisible(TRUE) Might get another use in the future.
Errors
In case of overwrite = FALSE and the file already exists an error is thrown.
Side-effects
Side effects are registered as 'passed' tests in the JUnit output and have been given a status "SIDE-EFFECT". The call and diff is also returned in the standard-output of the testcase tag.
They are not considred failures and would thus not stop a pipeline.
tinytests to JUnit
To comply the the JUnit specification the tests results are adapted as follows:
A single test run
tinytestsis mapped to a<testsuites>tag.All
tinytestresults from a single file are mapped to a single<testsuite>tag.The name of the testsuite is equal to the test file name (without the file suffix)
An individual
tinytestobject (eg. a singleexcept_*exception test) is mapped to a<testcase>tag.The name of the testcase is equal to the fileName + Line specification of where the expect statement is performed + the info.
For reference: https://llg.cubic.org/docs/junit/
See Also
The JUnit XML report format: https://llg.cubic.org/docs/junit/
Examples
# Run tests with `tinytest`
dirWithTests <- system.file("example_tests/multiple_files",package = "tinytest2JUnit")
testresults <- runTestDir(dirWithTests)
writeJUnit(testresults) # Writes content to stdout
tmpFile <- tempfile(fileext = ".xml")
writeJUnit(tinytests = testresults, file = tmpFile)