3 个版本 (重大更改)

0.3.0 2023年10月18日
0.2.0 2023年9月14日
0.1.0 2023年4月18日

#459 in 测试

Download history 5/week @ 2024-03-12 9/week @ 2024-03-19 5/week @ 2024-03-26 66/week @ 2024-04-02 5/week @ 2024-04-09 6/week @ 2024-04-23 4/week @ 2024-05-28

每月 68 次下载
用于 2 个工具包 (通过 wick-test)

Apache-2.0

12KB
285

tap-harness

这个库是一个包装器,用于编写以 Test Anything Protocol (TAP) 格式生成输出的测试。

用法

use tap_harness::{TestBlock, TestRunner};

fn main() -> anyhow::Result<()> {
  let mut runner = TestRunner::new(Some("My test"));

  let mut block = TestBlock::new(Some("My block"));

  block.add_test(
    || 3 > 2,
    "three is greater than two",
    Some(vec!["three was not greater".to_owned()]),
  );

  block.add_test(
    || 3 < 2,
    "three is less than two",
    Some(vec!["three was not less than two".to_owned()]),
  );

  runner.add_block(block);

  runner.run();

  let lines = runner.get_tap_lines();

  // or

  runner.print();

  Ok(())
}

这会打印

# My test
1..2
# My block
ok 1 three is greater than two
not ok 2 three is less than two
# three was not less than two

依赖项

~22KB