tcp-test 0.0.1

Test your TCP code
Documentation

tcp-test - Test your TCP code

travis-badge crates.io-badge license-badge

tcp-test is a Rust testing library to programmatically use real TCP in your tests.

Warning: Windows is currently not supported because of WSACancelBlockingCall exceptions.

Usage

Cargo.toml

[dev-dependencies]
tcp-test = "0.1"

Then simply use channel() in every test:

use tcp_test::channel;
use std::io::{self, Read, Write};

#[test]
fn some_test() {
    let (mut local, mut remote) = channel();
    
    let data = b"Hello, dear listener!";
    local.write_all(data).unwrap();
    
    let mut buf = Vec::new();
    remote.read_to_end(&mut buf).unwrap();
    
    assert_eq!(&buf, data);
}

#[test]
fn other_test() {
    let (mut local, mut remote) = channel();

    // ...
}