Class ReportGenerator
java.lang.Object
cloud.opencode.base.test.report.ReportGenerator
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 Summary
Modifier and TypeMethodDescriptionstatic StringtoHtml(TestReport report) Generates HTML report.static StringtoJson(TestReport report) Generates JSON report.static StringtoText(TestReport report) Generates text report.static voidwriteHtml(TestReport report, Writer writer) Writes HTML report to writer.static voidwriteHtml(TestReport report, Path path) Writes HTML report to file.static voidwriteJson(TestReport report, Path path) Writes JSON report to file.static voidwriteText(TestReport report, Writer writer) Writes text report to writer.
-
Method Details
-
toText
Generates text report. 生成文本报告。- Parameters:
report- the test report | 测试报告- Returns:
- the text | 文本
-
writeText
Writes text report to writer. 将文本报告写入writer。- Parameters:
report- the test report | 测试报告writer- the writer | writer
-
toHtml
Generates HTML report. 生成HTML报告。- Parameters:
report- the test report | 测试报告- Returns:
- the HTML | HTML
-
writeHtml
Writes HTML report to writer. 将HTML报告写入writer。- Parameters:
report- the test report | 测试报告writer- the writer | writer
-
writeHtml
Writes HTML report to file. 将HTML报告写入文件。- Parameters:
report- the test report | 测试报告path- the file path | 文件路径
-
toJson
Generates JSON report. 生成JSON报告。- Parameters:
report- the test report | 测试报告- Returns:
- the JSON | JSON
-
writeJson
Writes JSON report to file. 将JSON报告写入文件。- Parameters:
report- the test report | 测试报告path- the file path | 文件路径
-