Skip to content

Commit 4877f10

Browse files
bshastryclaude
andcommitted
Address review feedback: simplify TestResults implementation
- Remove unused testName parameter from recordPass() method - Remove totalTests field and calculate it dynamically in printSummary() from passed + failed counts - Simplify SEPARATOR constant by removing embedded newline and use explicit out.println() for consistent formatting - Add hasTests() helper method to check if any tests were executed This reduces redundant state tracking and improves code clarity. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 1c51a4f commit 4877f10

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

ethereum/evmtool/src/main/java/org/hyperledger/besu/evmtool/BlockchainTestSubCommand.java

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -96,36 +96,39 @@ public class BlockchainTestSubCommand implements Runnable {
9696

9797
/** Helper class to track test execution results for summary reporting. */
9898
private static class TestResults {
99-
private static final String SEPARATOR = "\n" + "=".repeat(80);
100-
private final AtomicInteger totalTests = new AtomicInteger(0);
99+
private static final String SEPARATOR = "=".repeat(80);
101100
private final AtomicInteger passedTests = new AtomicInteger(0);
102101
private final AtomicInteger failedTests = new AtomicInteger(0);
103102
private final Map<String, String> failures = new LinkedHashMap<>();
104103

105-
void recordPass(final String testName) {
106-
totalTests.incrementAndGet();
104+
void recordPass() {
107105
passedTests.incrementAndGet();
108106
}
109107

110108
void recordFailure(final String testName, final String reason) {
111-
totalTests.incrementAndGet();
112109
failedTests.incrementAndGet();
113110
failures.put(testName, reason);
114111
}
115112

113+
boolean hasTests() {
114+
return passedTests.get() + failedTests.get() > 0;
115+
}
116+
116117
void printSummary(final java.io.PrintWriter out) {
118+
final int totalTests = passedTests.get() + failedTests.get();
119+
out.println();
117120
out.println(SEPARATOR);
118121
out.println("TEST SUMMARY");
119-
out.println(SEPARATOR.substring(1)); // Skip leading newline for middle separator
120-
out.printf("Total tests: %d%n", totalTests.get());
122+
out.println(SEPARATOR);
123+
out.printf("Total tests: %d%n", totalTests);
121124
out.printf("Passed: %d%n", passedTests.get());
122125
out.printf("Failed: %d%n", failedTests.get());
123126

124127
if (!failures.isEmpty()) {
125128
out.println("\nFailed tests:");
126129
failures.forEach((testName, reason) -> out.printf(" - %s: %s%n", testName, reason));
127130
}
128-
out.println(SEPARATOR.substring(1)); // Skip leading newline for bottom separator
131+
out.println(SEPARATOR);
129132
}
130133
}
131134

@@ -193,7 +196,7 @@ public void run() {
193196
e.printStackTrace(System.err);
194197
} finally {
195198
// Always print summary, even if there were errors
196-
if (results.totalTests.get() > 0) {
199+
if (results.hasTests()) {
197200
results.printSummary(parentCommand.out);
198201
}
199202
}
@@ -306,7 +309,7 @@ private void traceTestSpecs(
306309
if (testFailed) {
307310
results.recordFailure(test, failureReason);
308311
} else {
309-
results.recordPass(test);
312+
results.recordPass();
310313
}
311314
}
312315

0 commit comments

Comments
 (0)