How it works...
Rust's built-in testing library is called libtest and it is what's invoked by cargo. Regardless of the type of project created (binary application or library), libtest runs the associated test and outputs the result. In this recipe, we are examining running the tests of a previously created project—however, these steps obviously work for any project with tests.
In step 2, we created a small library that features four tests, two of which print things to the command line just after waiting for a few seconds (five and ten seconds). This allows us to show threaded test running and that the test harness captures the output by default.
Other than filtering the list of available tests (we do that in step 4 and step 7) in the project, ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access