N
N
Nast22019-07-30 09:10:19
Unit testing
Nast2, 2019-07-30 09:10:19

Rust nested crate, how to run tests?

There is the following structure:
5d3fde325cbd3964799392.png
Crate in Cargo.toml is connected like this:

[dependencies]
reverse = { path = "reverse" }

The default test is defined in lib.rs itself:
#[cfg(test)]
mod tests {
    #[test]
    fn it_works() {
        assert_eq!(2 + 2, 4);
    }
}

But when you run cargo test , the test is simply not defined and does not run. What, why and how to fix?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrey Lesnikov, 2019-07-30
@Nast2

Why: because the crate was added as just a dependency, albeit a local one.
Fix: Add reverse to workspace: https://doc.rust-lang.org/book/ch14-03-cargo-works...
[workspace]
members = ["reverse"]

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question