A drawing of a giant crab standing in a village.

All Rust Workshops

Testing in Rust: an introduction

4 hours Bookable for teams – on-site or remote

About this workshop

Rust's type system is great, but it's not enough on its own to ensure correctness: a solid testing strategy is a requirement for any serious Rust application.

The workshop will build up your Rust's testing toolkit. We will start from scratch, with your first unit test. By the end, you will have a comprehensive understanding of the available test types, the best practices in terms of test organization as well as their runtime implications. You will be well equipped for the testing challenges ahead of you!

The workshop is designed for software developers who are just starting their Rust journey.

If you've been working with Rust for a while, you might be interested instead in our advanced testing workshop.

Bookable for teams

4 hours

On-site or remote

Book for your team

Syllabus

  1. Writing 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. Testing 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. The 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. Running 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. Test 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. Beyond 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).

Your mentor

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".

Our Attendees Say...

The individual exercises build on each other very well. Direct practice makes it easier to understand the topics. I have rarely taken part in such a good practical workshop!
Remote attendee
Amazing support from Luca! Detailed explanation of different topics whenever requested.
Onsite attendee

Who we are

Mainmatter has been active in the Rust ecosystem for years, creating the 100 Exercises to Learn Rust course, the C to Rust Migration Book organizing EuroRust, and contributing to open source.

We help teams adopt and build on Rust with confidence via trainings and workshops, hands-on team reinforcement, codebase assessments, and more.

We have trained developers at

Bookable for teams

4 hours

On-site or remote

Book for your team

Can't Find the Right Workshops for Your Team?

We are happy to tailor the curriculum to your needs. We can combine multiple workshops, pick and choose modules, as well as develop new content if desired.
Get in Touch

Book This Workshop

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

Send us a message

Your message is being sent…

Unable to send message.

Please try again later or contact us at [email protected]

Thank you!

We will be in touch soon.

Testing in Rust: an introduction