mercredi 20 mars 2019

How do I write tests for a module in rust?

I have a folder structure like this

Folder
|
|- main.rs
|- SomeModule |
              |
              |- mod.rs
              |- somefile.rs

In somefile.rs I have

pub struct MyStruct {
}

#[cfg(test)]
mod tests {
  #[test]
  pub fn it_works() {
    assert!(true)
  }
}

but when I run cargo test I don't see any of the tests from somefile.rs.

How do I fix this?

Aucun commentaire:

Enregistrer un commentaire