e007: Testify

Published: Dec. 13, 2015, 5:38 p.m.

b'

Notes

\\n

All about testing in Rust! In order, we take a look at:

\\n
    \\n
  • Why you need tests.
  • \\n
  • Unit tests in other (dynamically-typed) languages vs.\\xa0in Rust.
  • \\n
  • How to write unit tests in Rust.
  • \\n
  • How and why to write integration tests in Rust.
  • \\n
  • How and why to use benchmarks in Rust.
  • \\n
\\n

The detailed code samples for this episode are heavy on showing; because of the nature of test functions, you will be best off just reading the source rather than leaning heavily on the descriptions generated by rustdoc. (The descriptions are still there, but they\\u2019re much less useful than they have been in previous episodes.) In particular, the test module here is excluded because of the use of the #[cfg(test)] attribute marker on it.

\\n

Because we are using the feature-gated benchmarking functionality, the show notes \\u201clibrary\\u201d can now only be compiled with the Rust nightly (as of 1.5, the version current as this episode is produced).

\\n

One thing that isn\\u2019t necessarily obvious from reading the test documentation in the Rust book and Rust reference: the extern crate test statement needs to be not in this module, but at the module (lib.rs) which defines the library/crate; in this case, show_notes/lib.rs.

\\n\\n\\n

Sponsors

\\n
    \\n
  • Chris Palmer
  • \\n
  • Derek Morr
  • \\n
  • Luca Schmid
  • \\n
  • Micael Bergeron
  • \\n
  • Ralph Giles (\\u201crillian\\u201d)
  • \\n
  • reddraggone9
  • \\n
  • William Roe
  • \\n
\\n

Become a sponsor

\\n\\n

Follow

\\n'