Interface TestResultFormatter
- All Known Implementing Classes:
HumanTestFormatter, JsonTestFormatter, JUnitXmlFormatter, TerseTestFormatter
interface TestResultFormatter
Interface for formatting test results in different output formats.
Implementations handle terse, human-readable, JSON, and JUnit XML formats. Each format is optimized for a different audience:
- Terse: Scripting and CI pass/fail checks
- Human: Terminal output with visual hierarchy
- JSON: AI/LLM and programmatic access
- JUnit XML: CI/CD tools (Jenkins, GitHub Actions, GitLab)
All formatters must clearly communicate the test type (assert-based, simple blackbox, parameterized) to help users understand how tests are validated.
-
Method Summary
Modifier and TypeMethodDescriptionstatic TestResultFormattercreate(TestOutputFormat format, boolean verbose) Create a formatter for the specified output format.voidreportDiscovery(List<DiscoveredTest> tests, PrintStream out) Report the discovery of tests before execution begins.voidreportExecutionStart(int testCount, PrintStream out) Report that test execution is starting.voidreportResults(List<TestResult> results, PrintStream out) Report all test results after execution completes.
-
Method Details
-
reportDiscovery
Report the discovery of tests before execution begins.The discovery report should include:
- Test type breakdown (assert-based vs blackbox vs parameterized)
- Total test case count (including parameterized cases)
- Group information if applicable
- Parameters:
tests- The discovered tests with metadataout- The output stream
-
reportExecutionStart
Report that test execution is starting. Some formatters may output a progress message here.- Parameters:
testCount- The number of tests to executeout- The output stream
-
reportResults
Report all test results after execution completes.- Parameters:
results- The test resultsout- The output stream
-
create
Create a formatter for the specified output format.- Parameters:
format- The output formatverbose- Whether verbose output is enabled- Returns:
- The appropriate formatter
-