Rust Testing

Reproducible testing is important for reliable software development. Rust has a powerful built-in testing features, so that test can be writting under the test modules, and invoked by cargo test. For more details, see rust doc. This blogs will focus on some convenient use cases. How to Write Tests. fn plus_one(x: i32) -> i32 { x + 1 } fn main() { } #[cfg(test)] mod tests{ #[test] fn it_works() { assert_eq!(2, super::plus_one(1)); } } And fire the test with cargo test. ...

September 10, 2025 · 1 min · 174 words

Docker for Development and Testing

Docker is a virtualisation tool. It can create lightweight, fast, isolated, and reproducible environments like virtual machines, in which an application can be tested reliably. An docker image is a snapshot of an operating system. A container is an instance of an image, behaving like a running virtual machine. Testing Process Say I want to test a rust project with file structure like . ├── Cargo.lock ├── Cargo.toml ├── src │ └── main.rs └── target ├── CACHEDIR.TAG └── debug In a brand new operating system, everything needed to test this project is the rust-cargo suite, besides the source code. So I want the container to have them. ...

September 7, 2025 · 2 min · 400 words