Like Go and Elixir, Rust has first-class support for automated tests. Like Elixir, Rust also has support for Doctests, which is great.
Usually, tests are defined in the same file as the code under test. We create a new test
module and specify the cfg
attribute to conditionally compile the test module only in test mode. Tests are defined using the test
attribute, and in them we can use several assertion macros provided by the standard library to assert behavior.