Tests, Documentation, and Benchmarks

In this chapter, we will continue with Cargo and learn how to write tests, how to document our code, and how to measure the performance of our code with benchmark tests. We'll then put those skills to use and build a simple crate that simulates logic gates, giving you an end- to-end experience of writing unit and integration tests, as well as documentation tests.

In this chapter, we'll cover the following topics:

  • Motivation on testing
  • Organizing tests and testing primitives
  • Unit tests and integration tests
  • Documentation tests
  • Benchmark tests
  • Continuous integration with Travis CI

Get Mastering Rust - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.