Development dependencies
Sometimes there is a need to have dependencies for tests (or examples,
or benchmarks) only. Such dependencies are added to Scarb.toml in the
[dev-dependencies] section. These dependencies are not propagated to other
packages which depend on this package.
When you start a new project with scarb new, you will notice that the Scarb.toml file contains the assert_macros dev-dependency. This macro is required to use the assert_ macros presented in unit-testing.
File Scarb.toml:
[package]
name = "adder"
version = "0.1.0"
edition = "2024_07"
# See more keys and their definitions at https://docs.swmansion.com/scarb/docs/reference/manifest.html
[dependencies]
starknet = "2.9.2"
File src/lib.cairo:
fn add(a: u32, b: u32) -> u32 {
a + b
}
#[cfg(test)]
mod tests {
use super::add;
#[test]
fn test_add() {
assert_eq!(add(2, 3), 5);
}
}
See Also
Scarb docs on specifying dependencies.