You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
RA fails to parse the json output from cargo test if it doesn't include a stdout field which can happen depending on the cargo test flags used. This can be fixed by treating it as optional in test_runner::TestState e.g.
It's often necessary to see the stdout from println/trace/log generated during a unit test in the vscode Test Results window:
#[cfg(test)]pubmod tests {#[test]fnmy_test_fails(){println!("this is a message before failure");assert_eq!(2 + 2,5);}#[test]fnmy_test_works(){println!("this is a message before success");assert_eq!(2 + 2,4);}}
By default the stdout is swallowed by cargo test so we need to add the --nocapture flag in settings.json e.g.
This doesn't cause any issue with passing tests but it has a side-effect that stdout is no longer included in the json output which causes RA to fail to parse test failures so they appear as ignored and don't cause failure to bubble up to the module/package/workspace level e.g.
The raw output from the two command lines RA uses:
Summary
RA fails to parse the json output from
cargo test
if it doesn't include astdout
field which can happen depending on thecargo test
flags used. This can be fixed by treating it as optional intest_runner::TestState
e.g.Detailed Explanation
It's often necessary to see the stdout from
println
/trace
/log
generated during a unit test in the vscode Test Results window:By default the stdout is swallowed by
cargo test
so we need to add the--nocapture
flag insettings.json
e.g.This doesn't cause any issue with passing tests but it has a side-effect that stdout is no longer included in the json output which causes RA to fail to parse test failures so they appear as ignored and don't cause failure to bubble up to the module/package/workspace level e.g.
The raw output from the two command lines RA uses:
Without nocapture
cargo test --package test_example --no-fail-fast --manifest-path ./Cargo.toml -- my_test_fails -Z unstable-options --format=json --show-output
With nocapture
cargo test --package test_example --no-fail-fast --manifest-path ./Cargo.toml -- my_test_fails -Z unstable-options --format=json --show-output --nocapture
The text was updated successfully, but these errors were encountered: