writeJUnit {tinytest2JUnit} | R Documentation |
tinytests
-object into JUnit xml report.Write the tinytests
-object to a JUnit XML reporting file. If a tinytests2JUnit
is provided
(returned by runTestDir()
) more info will get reported.
writeJUnit(tinytests, file = stdout(), overwrite = TRUE)
tinytests |
|
file |
|
overwrite |
|
invisible(TRUE)
Might get another use in the future.
In case of overwrite = FALSE and the file already exists an error is thrown.
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.
To comply the the JUnit specification the tests results are adapted as follows:
A single test run tinytests
is mapped to a <testsuites>
tag.
All tinytest
results 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 tinytest
object (eg. a single except_*
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/
The JUnit XML report format: https://llg.cubic.org/docs/junit/
# 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)