rust-lang/rfcs — pull request #345 by reem (2014-10-02 08:04:35+00:00)
Title: Added #[test_main] RFC.

Add a `#[test_main]` attribute that overrides the behavior of the `--test`
compiler flag so that instead of building and running all `#[test]`s, it
instead just calls the function annotated `#[test_main]`.

This allows full overloading of the normal testing behavior by downstream
libraries which wish to provide more complex features than those offered by the
builtin testing suite - for instance, the ability to run something before each
test or before and after all tests.

Libraries can currently do this by forcing users to build with just `--cfg test`,
but this is a poor solution as this doesn't support `cargo test` and other
tools which assume the normal `--test` behavior.