diff options
| author | Paul Buetow <paul@buetow.org> | 2025-06-21 15:54:07 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2025-06-21 15:54:07 +0300 |
| commit | d3b697218773eaa5a3dd368705184726dbc0fa38 (patch) | |
| tree | e466fb78829c957f70e88ab92651896b49120856 /src/main/java/testing/VerificationResult.java | |
| parent | dedec9b18bafa2bcfdb05429f717f95f2236d811 (diff) | |
Implement headless testing framework for DS-Sim protocol simulations
- Created HeadlessSimulationRunner that loads and runs simulations without GUI
- Implemented LogCapture to intercept and store all simulation logs
- Added ProtocolVerifier for flexible pattern-based log verification
- Created test runners: standard, with logs, and clean (filters GUI errors)
- Implemented tests for all non-Raft protocols
- Added DummySimulatorFrame to satisfy GUI dependencies during loading
- Created CleanHeadlessRunner that filters GUI-related errors from output
- Updated run-tests.sh script with quiet mode option
- Documented the framework architecture and usage
The framework successfully runs protocol tests and verifies behavior through
log analysis. GUI errors occur internally due to tight coupling in DS-Sim
but are filtered in quiet mode for clean output.
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
Diffstat (limited to 'src/main/java/testing/VerificationResult.java')
| -rw-r--r-- | src/main/java/testing/VerificationResult.java | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/src/main/java/testing/VerificationResult.java b/src/main/java/testing/VerificationResult.java new file mode 100644 index 0000000..3678ea8 --- /dev/null +++ b/src/main/java/testing/VerificationResult.java @@ -0,0 +1,57 @@ +package testing; + +import java.util.Collections; +import java.util.List; +import java.util.stream.Collectors; + +/** + * Aggregated result of all verification rules applied to a simulation. + */ +public class VerificationResult { + private final List<RuleResult> ruleResults; + private final boolean allPassed; + + public VerificationResult(List<RuleResult> ruleResults) { + this.ruleResults = Collections.unmodifiableList(ruleResults); + this.allPassed = ruleResults.stream().allMatch(RuleResult::isPassed); + } + + public boolean passed() { + return allPassed; + } + + public List<RuleResult> getRuleResults() { + return ruleResults; + } + + public List<RuleResult> getFailedRules() { + return ruleResults.stream() + .filter(r -> !r.isPassed()) + .collect(Collectors.toList()); + } + + public String getFailureMessage() { + if (allPassed) { + return "All verification rules passed"; + } + + return "Failed rules:\n" + getFailedRules().stream() + .map(r -> " - " + r.getMessage()) + .collect(Collectors.joining("\n")); + } + + public String generateReport() { + StringBuilder sb = new StringBuilder(); + sb.append("=== Verification Report ===\n"); + sb.append("Total rules: ").append(ruleResults.size()).append("\n"); + sb.append("Passed: ").append(ruleResults.size() - getFailedRules().size()).append("\n"); + sb.append("Failed: ").append(getFailedRules().size()).append("\n\n"); + + sb.append("Results:\n"); + for (RuleResult result : ruleResults) { + sb.append(" ").append(result).append("\n"); + } + + return sb.toString(); + } +}
\ No newline at end of file |
