Writing Automated Tests
Testing in Oxide follows Rust's model: you write test functions annotated with
#[test] and run them with cargo test. Assertions are provided by the
standard library.
What You'll Learn
- How to write and run tests
- How to organize tests within a crate
- How to use common assertions
A Small Example
fn addTwo(value: Int): Int {
value + 2
}
#[test]
fn addsTwo() {
let result = addTwo(40)
assertEq!(result, 42)
}
The next sections dig into test organization, runtime options, and best practices for building reliable code.