Rustc's test framework as used by cargo test can only produce executables. Maybe you could combine something like linkme's distributed slice with a proc macro as alternative for #[test]. Basically you did have a distributed slice with all tests, a proc macro attribute that would add a test to this slice and then write a test harness iterating over the list of tests which you can then call from C/C++.