Creating a custom test harness for advanced test setups

By Manfred Tonch and Leon Matthes

Talk - Wednesday, 17 September
12:30

Most Rust developers are familiar with “cargo test” and the default cargo test runner. It’s straight-forward API let’s developers write unit tests quickly and easily, because who wants to write tests if it feels like a chore? But what to do if the default test harness isn’t compatible with your specific build setup? In real-world scenarios like mixed Rust and C/C++ code bases this can often be the case, especially if CMake or another C/C++ toolchain drive the build.

In this talk, you’ll gain a deeper understanding of the parts involved in Rust’s default test runner and learn a robust pattern to build a custom test harness that is fully under your control. The talk covers how to replace Rust’s default test runner with the libtest-mimic crate and how to do test discovery using the linkme crate. The end goal is a test harness that is customizable and can be integrated with CMake and CTest or any other test setup.

Speaker

Manfred Tonch

Manfred Tonch spent the past 12 years at KDAB, working primarily on cross-platform applications using Qt and C++. Recently, he started exploring Rust and its interoperability with C++, looking at how modern systems programming concepts can enhance existing C++ codebases.

Leon Matthes

Leon Matthes is a software engineer at KDAB who specializes in C++/Rust integration. For the last three years, Leon has worked on CXX-Qt, KDABs framework for Qt/Rust integration, where he has gained experience in integrating Rust into large legacy systems.