一個模塊包含多個測驗,如下所示:
#[cfg(test)]
mod tests_cases {
/*
#[test]
fn test_1() {
let a = 1;
let b = 2;
println!("{},{}", a, b);
assert_ne!(a, b);
}
*/
#[test]
fn test_2() {
let c = 1;
let d = 1;
println!("currently working on this: {},{}", c, d);
assert_eq!(c, d);
}
}
在使用列印輸出 ( cargo test -- --nocapture) 處理第二個測驗時,我不想看到第一個測驗的輸出。
是否有禁用注釋單元測驗的選項?
或者是否可以選擇只運行第二個單元測驗?
謝謝你。
uj5u.com熱心網友回復:
如果您#[test]從不需要的測驗中洗掉該屬性,cargo test則將忽略它。
uj5u.com熱心網友回復:
另一種選擇是添加#[ignore]屬性。
#[ignore]
#[test]
fn test_1() {
let a = 1;
let b = 2;
println!("{},{}", a, b);
assert_ne!(a, b);
}
這為測驗結果添加了一個漂亮的顏色。
test tests::test_1 ... ignored
test tests::test_2 ... ok
test result: ok. 1 passed; 0 failed; 1 ignored; 0 measured; 0 filtered out; finished in 0.03s
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/345891.html
上一篇:開玩笑錯誤:elements.getAttribute不是函式
下一篇:論據不一樣!通緝
