ejectest — eject your Rust tests

Inline tests are convenient — until your files grow too large.

Manually ejecting means editing one file and creating another. That's busywork.

$ cargo install ejectest $ ejectest src/lib.rs
lib.rs
pub fn add(a: i32, b: i32) -> i32 {
    a + b
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn test_add() {
        assert_eq!(add(1, 2), 3);
    }
}
lib.rs
pub fn add(a: i32, b: i32) -> i32 {
    a + b
}

#[cfg(test)]
#[path = "lib_tests.rs"]
mod tests;
lib_tests.rs
use super::*;

#[test]
fn test_add() {
    assert_eq!(add(1, 2), 3);
}