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

tinytests-object to convert to JUnit xml.

file

character(1) | connection: Full file path or connection object to write the JUnit xml content to. By default stdout() connection is used.

overwrite

logical(1): should the file be overwritten if it already exist? By default TRUE.

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:

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)

[Package tinytest2JUnit version 1.1.2 Index]