subtest 1.0.3

macro to easily use test setup code from one test function in another one
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
use serial_test::serial;
use subtest::subtest;

#[subtest]
#[test]
#[serial] // <-- inherited by the subtest, so the two never run at the same time
fn server_starts() {
    let listener = std::net::TcpListener::bind("127.0.0.1:39118").unwrap(); // <-- still a fixed port
    let port = listener.local_addr().unwrap().port();
    assert_eq!(port, 39118);

    #[subtest]
    fn server_accepts_a_connection() {
        std::net::TcpStream::connect(("127.0.0.1", port)).unwrap();
    }
}