Testing Rust: Series Introduction
Posted: 2018-02-24
The Rust programming language has solid basic facilities for testing built-in to the language and tools.
As part of my journey learning this language, I wanted to understand what kinds of techniques people are using to solve the standard set of testing problems - setting up fixtures, testing corner cases, injecting test doubles, etc - but in Rust. So I carried out a bit of a survey of well known code bases like futures, cargo, serde, and diesel to see how things are done.
I learned way more than I expected. More than I will attempt to cover in one post. So I have a plan a for a series. Here are the posts already available:
- Testing Rust: Helper Functions
- Testing Rust: Compile-time Helper Functions
- Testing Rust: Using the builder pattern for complex fixtures
Here are the ones on the plan, which have yet to be written:
- Coping with repetition (repeated test logic, repeated test data)
- Test doubles (temporary trait impls, mocks using RefCell, frameworks?)
- Test frameworks such as hamcrest
- Light weight smoke tests
- Cross platform tests
- How to test macros?
- Differences between Rust’s integration tests and unit tests