@@ -23,7 +23,7 @@ $ cd adder
2323Cargo will automatically generate a simple test when you make a new project.
2424Here's the contents of ` src/lib.rs ` :
2525
26- ``` rust
26+ ``` rust,ignore
2727# // The next line exists to trick play.rust-lang.org into running our code as a
2828# // test:
2929# // fn main
@@ -38,7 +38,7 @@ mod tests {
3838
3939For now, let's remove the ` mod ` bit, and focus on just the function:
4040
41- ``` rust
41+ ``` rust,ignore
4242# // The next line exists to trick play.rust-lang.org into running our code as a
4343# // test:
4444# // fn main
@@ -81,8 +81,10 @@ test it_works ... ok
8181Note the ` it_works ` . This comes from the name of our function:
8282
8383``` rust
84+ # fn main () {
8485fn it_works () {
8586}
87+ # }
8688```
8789
8890We also get a summary line:
@@ -94,7 +96,7 @@ test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured
9496So why does our do-nothing test pass? Any test which doesn't ` panic! ` passes,
9597and any test that does ` panic! ` fails. Let's make our test fail:
9698
97- ``` rust
99+ ``` rust,ignore
98100# // The next line exists to trick play.rust-lang.org into running our code as a
99101# // test:
100102# // fn main
@@ -169,7 +171,7 @@ This is useful if you want to integrate `cargo test` into other tooling.
169171
170172We can invert our test's failure with another attribute: ` should_panic ` :
171173
172- ``` rust
174+ ``` rust,ignore
173175# // The next line exists to trick play.rust-lang.org into running our code as a
174176# // test:
175177# // fn main
@@ -204,7 +206,7 @@ test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured
204206Rust provides another macro, ` assert_eq! ` , that compares two arguments for
205207equality:
206208
207- ``` rust
209+ ``` rust,ignore
208210# // The next line exists to trick play.rust-lang.org into running our code as a
209211# // test:
210212# // fn main
@@ -243,7 +245,7 @@ parameter can be added to the `should_panic` attribute. The test harness will
243245make sure that the failure message contains the provided text. A safer version
244246of the example above would be:
245247
246- ``` rust
248+ ``` rust,ignore
247249# // The next line exists to trick play.rust-lang.org into running our code as a
248250# // test:
249251# // fn main
@@ -280,7 +282,7 @@ some known arguments and compare it to the expected output.
280282Sometimes a few specific tests can be very time-consuming to execute. These
281283can be disabled by default by using the ` ignore ` attribute:
282284
283- ``` rust
285+ ``` rust,ignore
284286# // The next line exists to trick play.rust-lang.org into running our code as a
285287# // test:
286288# // fn main
0 commit comments