100 Days of Rust : Day 9 (Testing)
I continued reading Command Line Applications in Rust
Learnt that testing is easy. Any function that has #[test]
above it, will be
found (across any files) and used by cargo test
Couple of interesting crates :
- exitcode
- It has quite well defined exit codes. They come from FreeBSD
- I wish other languages / frameworks had something similar
- proptest
- is a property testing framework
- Based on python’s Hypothesis
- I need to spend time actually trying this
- human-panic
- Generates report file on
panic
- Shows nice (if a bit long) message to the user, asking them to (optionally) email the report file to the developer 🤯
- Generates report file on
Things to explore:
- Write code across files.
- So far my code is contained within
src/main.rs
😄
- So far my code is contained within
- Then move the tests in a separate files.