Testing before all hook


#1

I’m testing a binary which starts a server. Is there a way I could hook into the lifecycle of my tests to run the binary to launch a server before all my tests run and close the server processes at the end of my tests?


#2

Not in Rust itself at the moment. The in-built testing is pretty bare-bones, without special hooks. You can of course just trigger it externally, first launching the server, running tests, then shutting it down (e.g. do this using make or a simple shell script).

What redis-rs does is launching one server per test, keeping a context object per test: https://github.com/mitsuhiko/redis-rs/blob/master/tests/test_basic.rs#L21-L55