#proc-macro #ignore #testing #set #conditionally

test-ignore-if

一个用于条件性地忽略测试的Rust进程宏

1 个不稳定版本

0.1.0 2019年4月30日

#70 in #ignore

Apache-2.0

3KB

test-ignore-if

一个用于条件性地忽略测试的Rust进程宏

支持的条件

  • 构建时设置的构建时环境变量

使用方法

首先,您需要将以下行添加到您的 build.rs

test_ignore_if_utils::enable_ignore_if_env_set_for("CI")

这确保了如果 CI 环境变量更改,您的代码将被重新编译,并且告诉进程宏您已启用此功能

然后您可以注释您的测试

use test_ignore_if::ignore_if;

#[ignore_if(env_set="CI")]
#[test]
fn it_works() {
    assert_eq!(2 + 2, 4);
} 

如果 CI 环境变量在编译时已设置,则测试将被忽略

许可证

Copyright 2019 Thibaut Lorrain

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    https://apache.ac.cn/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

依赖项

~5.5MB
~106K SLoC