Skip to content

Commit

Permalink
auto merge of rust-lang#11654 : korenchkin/rust/doc_guide-testing_for…
Browse files Browse the repository at this point in the history
…mat, r=cmr
  • Loading branch information
bors committed Jan 20, 2014
2 parents a0ecb15 + e0ea31f commit 290c29c
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions doc/guide-testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured
# Unit testing in Rust

Rust has built in support for simple unit testing. Functions can be
marked as unit tests using the 'test' attribute.
marked as unit tests using the `test` attribute.

~~~
#[test]
Expand All @@ -44,13 +44,13 @@ fn return_none_if_empty() {

A test function's signature must have no arguments and no return
value. To run the tests in a crate, it must be compiled with the
'--test' flag: `rustc myprogram.rs --test -o myprogram-tests`. Running
`--test` flag: `rustc myprogram.rs --test -o myprogram-tests`. Running
the resulting executable will run all the tests in the crate. A test
is considered successful if its function returns; if the task running
the test fails, through a call to `fail!`, a failed `check` or
`assert`, or some other (`assert_eq`, ...) means, then the test fails.

When compiling a crate with the '--test' flag '--cfg test' is also
When compiling a crate with the `--test` flag `--cfg test` is also
implied, so that tests can be conditionally compiled.

~~~
Expand All @@ -64,17 +64,17 @@ mod tests {
~~~

Additionally `#[test]` items behave as if they also have the
`#[cfg(test)]` attribute, and will not be compiled when the --test flag
`#[cfg(test)]` attribute, and will not be compiled when the `--test` flag
is not used.

Tests that should not be run can be annotated with the 'ignore'
Tests that should not be run can be annotated with the `ignore`
attribute. The existence of these tests will be noted in the test
runner output, but the test will not be run. Tests can also be ignored
by configuration so, for example, to ignore a test on windows you can
write `#[ignore(cfg(target_os = "win32"))]`.

Tests that are intended to fail can be annotated with the
'should_fail' attribute. The test will be run, and if it causes its
`should_fail` attribute. The test will be run, and if it causes its
task to fail then the test will be counted as successful; otherwise it
will be counted as a failure. For example:

Expand All @@ -87,11 +87,11 @@ fn test_out_of_bounds_failure() {
}
~~~

A test runner built with the '--test' flag supports a limited set of
A test runner built with the `--test` flag supports a limited set of
arguments to control which tests are run: the first free argument
passed to a test runner specifies a filter used to narrow down the set
of tests being run; the '--ignored' flag tells the test runner to run
only tests with the 'ignore' attribute.
of tests being run; the `--ignored` flag tells the test runner to run
only tests with the `ignore` attribute.

## Parallelism

Expand Down

0 comments on commit 290c29c

Please sign in to comment.