Testing¶
Running Tests¶
# All tests
cargo test --all-features --workspace
# Specific crate
cargo test -p grafeo-core
# Single test with output
cargo test test_name -- --nocapture
# Release mode (catches optimization-specific issues)
cargo test --all-features --workspace --release
Python Tests¶
Node.js Tests¶
Coverage¶
CI uses cargo-llvm-cov (not tarpaulin) with the --all-features flag:
# Install cargo-llvm-cov
rustup component add llvm-tools-preview
cargo install cargo-llvm-cov
# Generate report (matches CI)
cargo llvm-cov --all-features --workspace --lcov --output-path lcov.info \
--ignore-filename-regex '(crates/bindings/|build\.rs|tests/|benches/)'
Coverage Targets¶
Crate names here match the workspace member paths used by cargo test -p <name>:
| Crate | Target |
|---|---|
| grafeo-common | 95% |
| grafeo-core | 90% |
| grafeo-adapters | 85% |
| grafeo-engine | 85% |
| Overall workspace | 82%+ |
Test Categories¶
- Unit tests - Same file,
#[cfg(test)]module - Integration tests -
tests/directory - Property tests - Using
proptestcrate
Writing Tests¶
#[cfg(test)]
mod tests {
use grafeo_common::types::ReadView;
use grafeo_core::graph::rowgroup::RowGroupStore;
use grafeo_core::graph::GraphStore;
#[test]
fn test_node_creation() {
let store = RowGroupStore::new();
let id = store.create_node(&["Person"]);
// A reader after every write the store holds.
assert!(store.node(id, ReadView::latest()).unwrap().is_some());
}
}