1 个不稳定版本
0.1.0 | 2021年12月20日 |
---|
#25 在 #manifest-file
每月21 次下载
在 2 crates 中使用
18KB
371 行
测试目录
这是一个简单的收集测试案例信息并导出为目录的工具。
首先,使用以下命令安装 test-catalog
二进制文件:cargo install test-catalog
.
要使用测试目录规范,请将依赖项添加到 Cargo 清单文件(Cargo.toml)中
[dev-dependecies]
proc-test-catalog = "0.1.0"
test-catalog = "0.1.0"
请注意,proc-test-catalog
crate 需要 nightly 频道才能编译。
然后,除了旧测试案例外,您应该在 #[test]
之后添加 #[proc_test_catalog::test_catalogue]
属性,并在文档行中添加案例描述。
#[test]
#[proc_test_catalog::test_catalogue(since = "0.1.0")]
/// This is preferred case description.
fn it_works() {
// some test codes.
println!("ok");
}
以下是 test_catalogue
proc 宏支持的完整属性列表
- since: 测试案例自特定版本以来添加。
- compatible_version: 与 TDengine 兼容的版本表达式,例如
^2.3.0 && ~2.5.0
或 ">2.0"。 - description: 使用此属性覆盖描述,否则将使用默认的文档描述。
然后,运行 cargo test
,并使用 test-catalog
工具导出测试目录。
关于测试案例的完整信息列表如下
- version: 当前应用程序版本
- file: 相对于主清单文件的测试案例所在文件路径。
- line_start: 测试案例在
file
中的起始行。 - line_end: 测试案例在
file
中的结束行。 - name: 测试案例函数名。
- description: 使用区分信息描述当前测试案例。
- since: 测试案例首次添加的版本。
- compatible_version: 仅适用于 TDengine,兼容 TDengine 版本的属性。
- authors: 测试案例的作者
- created_at:测试用例的创建时间(自纪元以来的秒数)。
- last_commit_id:测试用例的最后提交ID。
- last_committer:测试用例最后提交的签名作者。
- last_committed_at:测试用例的最后修改时间。
- elapsed:测试用例在纳秒级的时间消耗。
test-catalog
工具可以将测试目录导出为多种文件格式,包括markdown、confluence wiki标记、制表符分隔文本(tsv)、csv或json,默认为markdown。
例如,将测试目录导出为CSV
test-catalog -f csv
依赖关系
~36MB
~738K SLoC