Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

⚡ Improve test summary formatting #5731

Merged
merged 7 commits into from
Aug 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions crates/forge/bin/cmd/test/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -397,13 +397,13 @@ impl TestOutcome {
}
println!();
}

let successes = self.successes().count();
println!(
"Encountered a total of {} failing tests, {} tests succeeded",
Paint::red(failures.to_string()),
Paint::green(successes.to_string())
);

std::process::exit(1);
}

Expand All @@ -419,9 +419,9 @@ impl TestOutcome {
format!(
"Test result: {}. {} passed; {} failed; {} skipped; finished in {:.2?}",
result,
self.successes().count(),
failed,
self.skips().count(),
Paint::green(self.successes().count()),
Paint::red(failed),
Paint::yellow(self.skips().count()),
self.duration()
)
}
Expand Down Expand Up @@ -472,8 +472,12 @@ fn format_aggregated_summary(
) -> String {
let total_tests = total_passed + total_failed + total_skipped;
format!(
"Ran {} test suites: {} tests passed, {} failed, {} skipped ({} total tests)",
num_test_suites, total_passed, total_failed, total_skipped, total_tests
" \nRan {} test suites: {} tests passed, {} failed, {} skipped ({} total tests)",
num_test_suites,
Paint::green(total_passed),
Paint::red(total_failed),
Paint::yellow(total_skipped),
total_tests
)
}

Expand Down
1 change: 1 addition & 0 deletions crates/forge/tests/fixtures/can_check_snapshot.stdout
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ Compiler run successful!
Running 1 test for src/ATest.t.sol:ATest
[PASS] testExample() (gas: 168)
Test result: ok. 1 passed; 0 failed; 0 skipped; finished in 4.42ms

Ran 1 test suites: 1 tests passed, 0 failed, 0 skipped (1 total tests)
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ Compiler run successful!
Running 1 test for src/nested/forge-tests/MyTest.t.sol:MyTest
[PASS] testTrue() (gas: 168)
Test result: ok. 1 passed; 0 failed; 0 skipped; finished in 2.93ms

Ran 1 test suites: 1 tests passed, 0 failed, 0 skipped (1 total tests)
1 change: 1 addition & 0 deletions crates/forge/tests/fixtures/can_test_repeatedly.stdout
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ Running 2 tests for test/Counter.t.sol:CounterTest
[PASS] testFuzz_SetNumber(uint256) (runs: 256, μ: 26521, ~: 28387)
[PASS] test_Increment() (gas: 28357)
Test result: ok. 2 passed; 0 failed; 0 skipped; finished in 9.42ms

Ran 1 test suites: 2 tests passed, 0 failed, 0 skipped (2 total tests)
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ Compiler run successful!
Running 1 test for test/Contract.t.sol:ContractTest
[PASS] test() (gas: 70373)
Test result: ok. 1 passed; 0 failed; 0 skipped; finished in 3.21s

Ran 1 test suites: 1 tests passed, 0 failed, 0 skipped (1 total tests)
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ Compiler run successful!
Running 1 test for src/Contract.t.sol:ContractTest
[PASS] testExample() (gas: 190)
Test result: ok. 1 passed; 0 failed; 0 skipped; finished in 1.89ms

Ran 1 test suites: 1 tests passed, 0 failed, 0 skipped (1 total tests)
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ Compiler run successful!
Running 1 test for src/Contract.t.sol:ContractTest
[PASS] testExample() (gas: 190)
Test result: ok. 1 passed; 0 failed; 0 skipped; finished in 1.89ms

Ran 1 test suites: 1 tests passed, 0 failed, 0 skipped (1 total tests)