Updated Note testsuite (markdown)

Brian Anderson
2013-06-09 22:01:38 -07:00
parent e1c22c7406
commit 3a150e2504
+8 -2
@@ -153,13 +153,19 @@ run-pass/cci_iter_exe.rs:
## Unit Tests
Most crates include <a href="https://github.com/mozilla/rust/wiki/Doc-unit-testing">unit tests</a> which are part of the crate they test. These crates are built with the --test flag and run as part of `make check`.
Most crates include <a href="https://github.com/mozilla/rust/wiki/Doc-unit-testing">unit tests</a> which are part of the crate they test. These crates are built with the --test` flag and run as part of `make check`.
Tests should go near the code they test. If a module's tests require additional helper functions then they should be enclosed in a conditionally-compiled test module:
All tests in a module should go in an inner module named `test`, with the attribute `#[cfg(test)]`. Placing tests in their own module is a practical issue - because test cases are not included in normal builds, building with `--test` require a different set of imports than without, and that causes 'unused import' errors.
```
use std::option;
fn do_something() { ... }
#[cfg(test)]
mod test {
use std::vec;
fn helper_fn() { ... }
#[test]