• Stars
    star
    135
  • Rank 269,297 (Top 6 %)
  • Language
    Rust
  • Created about 1 year ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A Rust command that prettifies the ugly `cargo test` output into a beautiful one.

Cargo Pretty Test ✨

Testing Crates.io docs.rs

A Rust command-line tool that prettifies the ugly cargo test output into a beautiful output.

This crate can be also used as a library that fully parses the output from cargo test.

$ cargo pretty-test --workspace --no-fail-fast

Error details from `cargo test` if any ... (Omitted here)

Generated by cargo-pretty-test
β”œβ”€β”€ (OK) cargo_pretty_test ... (4 tests in 0.16s: βœ… 4)
β”‚   β”œβ”€β”€ (OK) tests/golden_master_test.rs ... (1 tests in 0.00s: βœ… 1)
β”‚   β”‚   └─ βœ… golden_master_test
β”‚   β”œβ”€β”€ (OK) tests/mocking_project.rs ... (2 tests in 0.16s: βœ… 2)
β”‚   β”‚   β”œβ”€ βœ… snapshot_testing_for_parsed_output
β”‚   β”‚   └─ βœ… snapshot_testing_for_pretty_output
β”‚   └── (OK) tests/parsing.rs ... (1 tests in 0.00s: βœ… 1)
β”‚       └─ βœ… parse_stderr_stdout
β”œβ”€β”€ (FAIL) integration ... (10 tests in 0.00s: βœ… 6; ❌ 2; πŸ”• 2)
β”‚   β”œβ”€β”€ (FAIL) src/lib.rs ... (8 tests in 0.00s: βœ… 4; ❌ 2; πŸ”• 2)
β”‚   β”‚   β”œβ”€β”€ submod
β”‚   β”‚   β”‚   β”œβ”€ πŸ”• ignore
β”‚   β”‚   β”‚   β”œβ”€ πŸ”• ignore_without_reason
β”‚   β”‚   β”‚   β”œβ”€ βœ… normal_test
β”‚   β”‚   β”‚   └── panic
β”‚   β”‚   β”‚       β”œβ”€ ❌ panicked
β”‚   β”‚   β”‚       β”œβ”€ βœ… should_panic - should panic
β”‚   β”‚   β”‚       β”œβ”€ ❌ should_panic_but_didnt - should panic
β”‚   β”‚   β”‚       └─ βœ… should_panic_without_reanson - should panic
β”‚   β”‚   └─ βœ… works
β”‚   β”œβ”€β”€ (OK) src/main.rs ... (1 tests in 0.00s: βœ… 1)
β”‚   β”‚   └─ βœ… from_main_rs
β”‚   └── (OK) tests/parsing.rs ... (1 tests in 0.00s: βœ… 1)
β”‚       └─ βœ… from_integration
└── (OK) Doc Tests ... (2 tests in 0.41s: βœ… 2)
    β”œβ”€β”€ (OK) cargo-pretty-test ... (1 tests in 0.20s: βœ… 1)
    β”‚   └─ βœ… src/doc.rs - doc (line 3)
    └── (OK) integration ... (1 tests in 0.21s: βœ… 1)
        └─ βœ… tests/integration/src/lib.rs - doc (line 41)

Status: FAIL; total 16 tests in 0.57s: 12 passed; 2 failed; 2 ignored; 0 measured; 0 filtered out

More screenshots.

Usage

Install:

cargo install cargo-pretty-test

Run in your project:

cargo pretty-test

Note: all the arguments passed to cargo pretty-test are forwarded to cargo test.


Run in CI as a summary: demo

      - id: pretty-test
        name: Run cargo pretty-test
        run: |
          cargo install cargo-pretty-test
          cargo pretty-test --color=always
          echo '```text' >> $GITHUB_STEP_SUMMARY
          echo "$(cargo pretty-test --color=never)" >> $GITHUB_STEP_SUMMARY 2>&1
          echo '```' >> $GITHUB_STEP_SUMMARY

Note: --color=always produces texts in color when running CI, and --color=never strips ANSI escapes before written to summary.

Credits

Links