package
17.15.0+incompatible
Repository: https://github.com/thought-machine/please.git
Documentation: pkg.go.dev

# README

Please Tests

Reporting

Tests are reported in much the same output format as the Maven Surefire Plugin. This makes it easy to consume the results in popular CI tools with a minimum of effort.

After executing plz test against one or more targets, the test results are written to plz-out/log/test_results.xml.

We no longer support the idea of "expected failures" as people who write tests they expect to fail will find they are first against the wall when the revolution comes.

Executing

Executing plz test against a target produces a set of results that are collated into one core.TestSuite with the package and name matching the target's label (this is a slight departure from the normal package/classname decomposition as it does not particularly translate well to non-Java languages).

If any tests fail, and the target is marked as flaky, it will be run again (up to flaky times). Tests can also be explicitly run multiple times by passing --num-runs n on the command line. We no longer accept a default of 0 as running a test 0 times is (a) not useful and (b) not what actually happened.

Each executed test during this target becomes a core.TestExecution under a core.TestCase in this test suite - so that multiple executions of a test are put together. We ignore multiple successes or skips as they are not interesting. In the case of a flaky test where some runs succeed and some fail, we store at most one success but also all of the failures and errors.

The time of the testsuite is the total time it took to execute all of the tests (including any re-runs for flakes).

Once all of the targets have been executed, these core.TestSuites are collected into one core.TestSuites object. This is then rendered as XML to the output file mentioned above.

# Functions

AddOriginalTargetsToCoverage adds empty coverage entries for any files covered by the original query that we haven't discovered through tests to the overall report.
CalculateIncrementalStats works out incremental coverage statistics based on a set of changed lines from files.
CopySurefireXMLFilesToDir copies all the XML test results files into the given directory.
CountCoverage counts the number of lines covered and the total number coverable in a single file.
LoadPreviousFailures loads any failed tests from the given results file.
RemoveFilesFromCoverage removes any files with extensions matching the given set from coverage.
RemoveTestOutputs removes any cached test or coverage result files for a target.
SerialiseResultsToXML serialises some test results to the "standard" XML format.
Test runs the tests for a single target.
No description provided by the author
WriteCoverageToFileOrDie writes the collected coverage data to a file in JSON format.
WriteResultsToFileOrDie writes test results out to a file in xUnit format.
WriteXMLCoverageToFileOrDie writes the collected coverage data to a file in XML format.

# Structs

IncrementalStats is a struct describing summarised stats for incremental coverage info.