Class ReportGenerator

java.lang.Object
cloud.opencode.base.test.report.ReportGenerator

public final class ReportGenerator extends Object
Report Generator - Generates test reports in various formats 报告生成器 - 以各种格式生成测试报告

Generates test reports in text, HTML, and JSON formats.

以文本、HTML和JSON格式生成测试报告。

Features | 主要功能:

  • Text report generation - 文本报告生成
  • HTML report with styled output - 带样式的HTML报告
  • JSON report for programmatic consumption - JSON报告用于程序化消费
  • File output support - 文件输出支持

Usage Examples | 使用示例:

TestReport report = new TestReport("MyTests", 10, 8, 2, Duration.ofSeconds(5));

// Generate text report
String text = ReportGenerator.toText(report);

// Generate HTML report
String html = ReportGenerator.toHtml(report);

// Write to file
ReportGenerator.writeHtml(report, Path.of("report.html"));

Security | 安全性:

  • Thread-safe: Yes (stateless utility class) - 线程安全: 是(无状态工具类)
  • Null-safe: Yes (validates non-null report) - 空值安全: 是(验证非空报告)
Since:
JDK 25, opencode-base-test V1.0.0
Author:
Leon Soo www.LeonSoo.com
See Also:
  • Method Details

    • toText

      public static String toText(TestReport report)
      Generates text report. 生成文本报告。
      Parameters:
      report - the test report | 测试报告
      Returns:
      the text | 文本
    • writeText

      public static void writeText(TestReport report, Writer writer)
      Writes text report to writer. 将文本报告写入writer。
      Parameters:
      report - the test report | 测试报告
      writer - the writer | writer
    • toHtml

      public static String toHtml(TestReport report)
      Generates HTML report. 生成HTML报告。
      Parameters:
      report - the test report | 测试报告
      Returns:
      the HTML | HTML
    • writeHtml

      public static void writeHtml(TestReport report, Writer writer)
      Writes HTML report to writer. 将HTML报告写入writer。
      Parameters:
      report - the test report | 测试报告
      writer - the writer | writer
    • writeHtml

      public static void writeHtml(TestReport report, Path path)
      Writes HTML report to file. 将HTML报告写入文件。
      Parameters:
      report - the test report | 测试报告
      path - the file path | 文件路径
    • toJson

      public static String toJson(TestReport report)
      Generates JSON report. 生成JSON报告。
      Parameters:
      report - the test report | 测试报告
      Returns:
      the JSON | JSON
    • writeJson

      public static void writeJson(TestReport report, Path path)
      Writes JSON report to file. 将JSON报告写入文件。
      Parameters:
      report - the test report | 测试报告
      path - the file path | 文件路径