6 Unit testing

This chapter covers

  • Understanding how unit testing is unique in Rust
  • Exploring unit testing dos and don’ts, features, and frameworks
  • Discussing unit testing with parallel code
  • Writing unit tests that consider refactoring
  • Exploring tools to help with refactoring
  • Measuring code covered by tests
  • Testing strategies for dealing with Rust’s ecosystem

Unit testing is one way to improve code quality, as it can catch regressions and ensure code meets requirements before shipping. Rust includes a built-in unit testing framework to make your life easier. In this chapter, we’ll review some of the features Rust provides and discuss some of the shortfalls of Rust’s unit testing framework—and how to overcome them.

6.1 How testing is different ...

Get Code Like a Pro in Rust 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.