Class JsonTestFormatter

java.lang.Object
org.ek9lang.cli.JsonTestFormatter
All Implemented Interfaces:
TestResultFormatter

final class JsonTestFormatter extends Object implements TestResultFormatter
JSON test output formatter (-t2). Structured output optimized for AI/LLM integration and programmatic consumption.

Output includes comprehensive test type information:

{
  "summary": {
    "total": 4,
    "passed": 3,
    "failed": 1,
    "types": {
      "assert": 1,
      "blackbox": 1,
      "parameterized": 2
    }
  },
  "tests": [
    {
      "name": "SimpleTest",
      "fqn": "test.module::SimpleTest",
      "source_file": "/path/to/test.ek9",
      "test_type": "assert",
      "case_id": null,
      ...
    },
    {
      "name": "ParamTest",
      "fqn": "test.module::ParamTest",
      "source_file": "/path/to/test.ek9",
      "test_type": "parameterized",
      "case_id": "hello",
      ...
    }
  ]
}

All output is valid JSON that can be piped to jq or parsed by any JSON library.

  • Constructor Details

    • JsonTestFormatter

      JsonTestFormatter()
  • Method Details

    • reportDiscovery

      public void reportDiscovery(List<DiscoveredTest> tests, PrintStream out)
      Description copied from interface: TestResultFormatter
      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
      Specified by:
      reportDiscovery in interface TestResultFormatter
      Parameters:
      tests - The discovered tests with metadata
      out - The output stream
    • reportExecutionStart

      public void reportExecutionStart(int testCount, PrintStream out)
      Description copied from interface: TestResultFormatter
      Report that test execution is starting. Some formatters may output a progress message here.
      Specified by:
      reportExecutionStart in interface TestResultFormatter
      Parameters:
      testCount - The number of tests to execute
      out - The output stream
    • reportResults

      public void reportResults(List<TestResult> results, PrintStream out)
      Description copied from interface: TestResultFormatter
      Report all test results after execution completes.
      Specified by:
      reportResults in interface TestResultFormatter
      Parameters:
      results - The test results
      out - The output stream