frondeus / frondeus/test-case

test_case with `=> panics` fails when test_case panics

Open
#153 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
633
Forks
42
PR merge metrics
No merged PRs in 30d

Description

A `test_case` with idiom `=> panics` will see an assert panic as a test case failure. It should see it as a test case passing. This appears to have been introduced between 3.2.1 and 3.3.1.

### Reproduction

Given this code in `main.rs`
```rust
fn main() {
println!("Hello, world!");
}

use ::test_case::test_case;

#[test_case(1, 2 => panics; "case 1, panics")]
#[test_case(3, 2; "case 2, okay")]
fn test_add_5(a: i32, b: i32) {
assert_eq!(a + b, 5);
}
```
and `Cargo.toml`
```toml
[package]
name = "try_test_case_panic"
version = "0.1.0"
edition = "2024"

[dependencies]
test-case = "=3.3.1"
```

test it
```text
‣ cargo test
Compiling try_test_case_panic v0.1.0 (/home/user/Projects/try_test_case_panic)
Finished `test` profile [unoptimized + debuginfo] target(s) in 0.38s
Running unittests src/main.rs (target/debug/deps/try_test_case_panic-1f556c442534e591)

running 2 tests
test test_add_5::case_2_okay ... ok
test test_add_5::case_1_panics ... FAILED

failures:

---- test_add_5::case_1_panics stdout ----

thread 'test_add_5::case_1_panics' (1124093) panicked at src/main.rs:10:5:
assertion `left == right` failed
left: 3
right: 5
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

failures:
test_add_5::case_1_panics

test result: FAILED. 1 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

error: test failed, to rerun pass `--bin try_test_case_panic`
```

With a prior version of `test-case` version `3.2.1` this does not occur.

Using rust 1.94.0 on Ubuntu 24,

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the reproduction in main.rs and its dependency declaration in Cargo.toml, then run cargo test using test-case 3.3.1 and compare it with 3.2.1. Trace the test_case handling for the => panics case. Done means the panicking case passes while the ordinary case continues to pass.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
testing-qa
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.