Is there a way to execute a teardown function after all tests have been run?

Here is an example implementation of the custom test framework solution mentioned by Masklinn: #![feature(custom_test_frameworks)] #![feature(test)] #![test_runner(custom_test_runner)] extern crate test; use test::{test_main_static, TestDescAndFn}; fn main() {} pub fn custom_test_runner(tests: &[&TestDescAndFn]) { println!(“Setup”); test_main_static(tests); println!(“Teardown”); } #[cfg(test)] mod tests { #[test] fn test1() { println!(“Test 1”) } #[test] fn test2() { println!(“Test 2”) } } This … Read more

What order are the Junit @Before/@After called?

Yes, this behaviour is guaranteed: @Before: The @Before methods of superclasses will be run before those of the current class, unless they are overridden in the current class. No other ordering is defined. @After: The @After methods declared in superclasses will be run after those of the current class, unless they are overridden in the … Read more