Class TestReport
java.lang.Object
cloud.opencode.base.test.report.TestReport
Test Report
测试报告
Collects and stores test results.
收集和存储测试结果。
Features | 主要功能:
- Test result collection and reporting - 测试结果收集和报告
- Multiple output formats - 多种输出格式
Usage Examples | 使用示例:
TestReport report = new TestReport("MySuite");
report.addPassed("test1", Duration.ofMillis(50));
report.complete();
System.out.println(report.getSummary());
Security | 安全性:
- Thread-safe: Yes (immutable) - 线程安全: 是(不可变)
- Since:
- JDK 25, opencode-base-test V1.0.0
- Author:
- Leon Soo www.LeonSoo.com
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordTest result 测试结果static enumTest status 测试状态 -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidadd(TestReport.TestResult result) Add test result 添加测试结果voidAdd failed test 添加失败的测试voidAdd passed test 添加通过的测试voidaddSkipped(String testName, String reason) Add skipped test 添加跳过的测试booleanCheck if all tests passed 检查是否所有测试都通过voidcomplete()Mark report as complete 标记报告为完成longAlias for getTotalDuration().toMillis()intAlias for getFailedCount()intGet failed count 获取失败数getName()Get report name 获取报告名称intGet passed count 获取通过数Get all results 获取所有结果intGet skipped count 获取跳过数doubleGet success rate 获取成功率Get summary 获取摘要intGet total count 获取总数Get total duration 获取总时长intAlias for getPassedCount()intAlias for getSkippedCount()doubleAlias for getSuccessRate()Alias for getName()Alias for getResults()Alias for Instant.now()toString()intAlias for getTotalCount()
-
Constructor Details
-
TestReport
-
-
Method Details
-
add
Add test result 添加测试结果- Parameters:
result- the result | 结果
-
addPassed
-
addFailed
-
addSkipped
-
complete
public void complete()Mark report as complete 标记报告为完成 -
getName
-
getResults
-
getTotalCount
public int getTotalCount()Get total count 获取总数- Returns:
- the count | 数量
-
getPassedCount
public int getPassedCount()Get passed count 获取通过数- Returns:
- the count | 数量
-
getFailedCount
public int getFailedCount()Get failed count 获取失败数- Returns:
- the count | 数量
-
getSkippedCount
public int getSkippedCount()Get skipped count 获取跳过数- Returns:
- the count | 数量
-
getTotalDuration
-
allPassed
public boolean allPassed()Check if all tests passed 检查是否所有测试都通过- Returns:
- true if all passed | 如果全部通过返回true
-
getSuccessRate
public double getSuccessRate()Get success rate 获取成功率- Returns:
- the success rate (0-1) | 成功率(0-1)
-
getSummary
-
toString
-
suiteName
Alias for getName() -
timestamp
Alias for Instant.now() -
totalTests
public int totalTests()Alias for getTotalCount() -
passedTests
public int passedTests()Alias for getPassedCount() -
failedTests
public int failedTests()Alias for getFailedCount() -
skippedTests
public int skippedTests()Alias for getSkippedCount() -
successRate
public double successRate()Alias for getSuccessRate() -
durationMs
public long durationMs()Alias for getTotalDuration().toMillis() -
testCases
Alias for getResults()
-