Expand description
This library provides a framework for defining and running End-to-End tests on network service for Rust. It allows users to define test cases with multiple tests, and provides a global fixture for all of them.
§Usage
See this simple example:
#[derive(clap::Args)]
struct Args {
#[arg(short, long, default_value = "127.0.100.1")]
dns_ip: Ipv4Addr,
}
fn init(args: &Args) {
}
#[derive(Clone)]
struct Fixture {
dns_ip: Ipv4Addr,
}
async fn fixture(args: &Args) -> Fixture {
Fixture {
dns_ip: args.dns_ip,
}
}
async fn init_testcase(fixture: Fixture) {
}
async fn cleanup_testcase(fixture: Fixture) {
}
async fn test_dns_ip(fixture: Fixture) {
assert_eq!(fixture.dns_ip, Ipv4Addr::new(127, 0, 100, 1));
}
async fn register() -> Vec<(String, TestCase<Fixture>)> {
let timeout = Duration::from_secs(10);
let testcase = TestCase::empty()
.with_init(timeout, init_testcase)
.with_cleanup(timeout, cleanup_testcase)
.with_test("dns_ip", timeout, test_dns_ip);
vec![("simple".to_string(), testcase)]
}
e2etest::run(["validator", "run"], init, register, fixture).unwrap();Structs§
- Test
Case - Represents a single test case, which can include initialization, multiple tests, and cleanup.
Functions§
- executable_
exists - Checks if the file exists and is executable.
- file_
exists - Checks if the file exists.
- run
- Main entry point for running tests.