Tests: function that run before anything else


Is any way to run function before any of tests during cargo test?


fn test_setup() {}

fn test1() {}

fn test2() {}

and test_setup will run before anything else?


No, the current test runner does not have such functionality. You have to call test_setup yourself in every test method instead.
Some external testing frameworks provide this functionality by wrapping everything into a macro and effectively generating the same code as you could manually do.