Member-only story
Testing in Rust
In this article, we will cover the subject of testing in Rust. We will see how easily we can add some tests to a Rust application and library.
One of the common stereotypes of software engineers is that we spend most of our time writing new code.
This assumption can't be further from the reality; As I explain in one of my past articles on design documentation(article here), software engineers invest a lot of time designing, supporting, and debugging existing source code.
This explains why having a well-written code source correctly tested with extensive coverage is crucial.
“Program testing can be a very effective way to show the presence of bugs, but is hopelessly inadequate for showing their absence.” Edsger Dijkstra
Testing is complex; let me rephrase that- testing is really hard.
As a practitioner of Test-Driven Development approach (more on TDD here), I often spend more time implementing my tests than on the feature checks by those tests. Also, don't get me started on the different types of tests, or we will be spending quite some time here 😅.
So how does testing work in Rust? Does Rust have dedicated libraries(crates) for testing like python? How should we organize our tests?