Crate test_with

source ·
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"] }

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 when memory size enough
  • 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 swap size enough
  • Run test case when socket connected
  • Run test case when runner is specific user