cargo-pretty-test 0.2.5

A console command to format cargo test output
Documentation
# Cargo Pretty Test ✨

[![Testing](https://github.com/josecelano/pretty-test/actions/workflows/testing.yaml/badge.svg)](https://github.com/josecelano/pretty-test/actions/workflows/testing.yaml)
[![Crates.io](https://img.shields.io/crates/v/cargo-pretty-test)](https://crates.io/crates/cargo-pretty-test)
[![docs.rs](https://img.shields.io/docsrs/cargo-pretty-test)](https://docs.rs/cargo-pretty-test)

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][parsing] the output from `cargo test`.

[parsing]: https://docs.rs/cargo-pretty-test/*/cargo_pretty_test/parsing/index.html

```console
$ 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
```

![](https://user-images.githubusercontent.com/25300418/270264132-89de6fd2-11f8-4e5b-b9dc-8475fa022a5f.png)

[More screenshots.](https://github.com/josecelano/cargo-pretty-test/wiki/cargo%E2%80%90pretty%E2%80%90test-screenshots)

## Usage

Install:

```console
cargo install cargo-pretty-test
```

Run in your project:

```console
cargo pretty-test
```

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

---

Run in CI as a summary: [demo](https://github.com/josecelano/cargo-pretty-test/actions/runs/6334295212)

```console
      - 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
          echo '```' >> $GITHUB_STEP_SUMMARY
```

![](https://user-images.githubusercontent.com/25300418/271169701-6efc57fb-9ab3-4842-9599-aa5784001c36.png)

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

## Credits

- First commit author [@ZJPzjp]https://github.com/zjp-CN.
- Idea described on [https://users.rust-lang.org]https://users.rust-lang.org/t/cargo-test-output-with-indentation/100149 by [@josecelano]https://github.com/josecelano.

### Links

- <https://users.rust-lang.org/t/cargo-test-output-with-indentation/100149>
- <https://www.rustexplorer.com/b/i058g3>