Expand description
test_with
provides env, file, path, http, https,
icmp, tcp, root, group, user, mem, swap,
cpu_core, phy_core, executable macros to help you run test case only
with the condition is fulfilled. If the #[test]
is absent for the test case, #[test_with]
will add it to the test case automatically.
This crate help you easier make integrating test case and has a good cargo summary on CI server, and will not affect on your binary output when you dependent it as dev-dependency as following.
[dev-dependencies]
test-with = "*"
All features will be opt-in default feature, so this crate will be easier to use, if you using a CI server with really limitation resource and want this crate as slim as possible, you can select the feature you want as following.
[dev-dependencies]
test-with = { version = "*", default-features = false, features = ["net"] }
The solution to have a real runtime condition check, we need to put the test as normal function
as an example, then use cargo run --example
The test-with
need be included as normal dependency with runtime
feature.
And also include the libtest-with
with corresponding features in Cargo.toml
runner and module are for the basic skeleton of the test runner.
runtime_env, runtime_no_env, runtime_file, runtime_path,
runtime_http, runtime_https, runtime_icmp, runtime_tcp,
runtime_root, runtime_group, runtime_user, runtime_mem,
runtime_free_mem, runtime_available_mem, runtime_swap,
runtime_free_swap, [macro@runtime_available_swap], runtime_cpu_core,
[macro@runtime_phy_core], runtime_executable and runtime_ignore_if are
used to transform a normal function to a
testcase.
[dependencies]
test-with = { version = "*", default-features = false, features = ["runtime"] }
libtest-with = { version = "0.6.1-6", features = ["net", "resource", "user", "executable"] }
// write as example in examples/*rs
test_with::runner!(env);
#[test_with::module]
mod env {
#[test_with::runtime_env(PWD)]
fn test_works() {
assert!(true);
}
}
Macros§
- Provide a test runner and test on each module
Attribute Macros§
- Run test case when cpu core enough
- Run test case when the environment variable is set.
- Run test case when the executables exist.
- Run test case when the file exist.
- Run test case when runner in group
- Run test case when the http service exist.
- Run test case when the https service exist.
- Run test case when the server online. Please make sure the role of test case runner have capability to open socket
- Run test case one by one when the lock is acquired It will automatically implement a file lock for the test case to prevent it run in the same time. Also, you can pass the second parameter to specific the waiting seconds, default will be 60 seconds.
- Run test case when memory size enough
- Help each function with
#[test_with::runtime_*]
in the module can register to run Also you can set up a mock instance for all of the test in the module - Ignore test case when the environment variable is set.
- Run test case when the path(file or folder) exist.
- Run test case when physical cpu core enough
- Run test case when runner is root
- Run test case when the example running and available memory size enough
- Run test case when cpu core enough
- Run test case when the example running and the environment variable is set.
- Run test case when the executable existing
- Run test case when the example running and the file exist.
- Run test case when the example running and free memory size enough
- Run test case when the example running and free swap enough
- Run test case when runner in group
- Run test case when the example running and the http service exist.
- Run test case when the example running and the http service exist.
- Run test case when the example running and the server online. Please make sure the role of test case runner have capability to open socket
- Ignore test case when function return some reason The function should be
fn() -> Option<String>
- Run test case when the example running and memory size enough
- Ignore test case when the example running and the environment variable is set.
- Run test case when the example running and the path(file or folder) exist.
- Run test case when physical core enough
- Run test case when runner is root
- Run test case when the example running and swap enough
- Run test case when the example running and socket connected
- Run test case when runner is specific user
- Run test case when swap size enough
- Run test case when socket connected
- Run test case when runner is specific user