Back to course

Automated Tests in Rust

Rust for Systems & Web3 Security

Quality Assurance Built-in

Rust has a built-in test runner. You write tests in the same file as your code, inside a module marked with #[cfg(test)].

rust #[test] fn it_works() { assert_eq!(2 + 2, 4); }

Importance in Web3

Before deploying a Smart Contract, you must have 100% test coverage. Rust makes this easy with unit tests and integration tests in the tests/ directory.