rust-lang/rfcs — pull request #229 by reem (2014-09-09 18:56:47+00:00)
Title: Expand #[test] and #[bench]

Rust's current testing and benchmarking system is an extremely valuable part of
the language, as it encourages even new users to write their own tests and
benchmarks without introducing the overhead of learning a new testing
framework.

However, in an effort to be simple, it also makes writing tests or benchmarks
that need to work around certain API constraints very difficult - mostly those
which require one or many time initialization and cleanup.

In other languages, this problem is solved by hooks exposed by outside testing
frameworks which give before, after, before\_each, and after\_each hooks. There
have been attempts to use macros to provide similar functionality in Rust, and
they mostly succeed in providing before\_each and after\_each. But, because
rustc doesn't provide the appropriate hooks, they cannot implement before and
after.

This RFC seeks to remedy this by providing these hooks and making them
ergonomic to use.