A drawing of a giant crab standing in a village.

Workshop: 4 hours

Testing in Rust: an introduction

Bookable for teams – on-site or remote

anchorWorkshop description

anchorWorkshop overview

  1. anchorWriting your first unit test

    Straight into the action: the #[test] annotation and basic assertions! We will wire everything up and get our feedback loop going.

  2. anchorTesting failures

    Unhappy scenarios are often more important than the happy ones! We will discuss the #[should_panic] annotation as well as the tradeoffs of returning a Result from your tests.

  3. anchorThe Rust testing zoo

    Unit tests are just of the test approaches offered by Rust's built-in testing framework—we have integration and doc tests too. We will look at each category and build a mental framework for choosing the correct testing technique in each context.

  4. anchorRunning your tests

    What is a test? We will take a look under the hood to understand how the Rust built-in testing framework is actually implemented. Armed with this knowledge, we will explore the runtime implications of different approaches for test organisation. We will also cover alternative test runners, such as cargo-nextest.

  5. anchorTest helpers: where do they go?

    Test code is just as important as production code: you want it to be terse and clearly communicate what is being tested. If you follow this philosophy, you'll soon be trying to extract common logic into test helpers: where should they be located? We will cover the different strategies available (test modules, feature gate, helper crate) and their trade-offs.

  6. anchorBeyond assertions

    In closing, we will have a look at a few advanced techniques beyond the standard toolkit: snapshot testing (insta) and property-based testing (quickcheck).

anchorYour mentor

Luca Palmieri

Luca Palmieri

Principal Engineering Consultant

Luca Palmieri builds technology products for a living. His current focus is on backend development, software architecture and the Rust programming language. He is the author of "Zero to Production in Rust".

Three smiling team members looking at a laptop

Book this workshop

Our mentors look forward to working with your team and unlocking new capabilities.
Get in touch