-2

I'm new to Rust and I'm currently trying to create test cases for a refactored version of an existing script. I noticed that for some reason whenever I run cargo test, I first receive the message "running 0 tests" and then "running x tests" (where x the number of tests I have written).

How can I find the source of "running 0 tests"?

kmdreko
  • 42,554
  • 6
  • 57
  • 106
  • 1
    Please provide the exact text output you're seeing. – PitaJ May 05 '22 at 15:37
  • 2
    Could you show the full output of `cargo test`, your code, or even both? By default, `cargo test` also tries to run doc tests, but there is a heading in the output indicating that. – Sven Marnach May 05 '22 at 15:37

1 Answers1

5

Rust splits its testing suite into two categories: Unit and integration tests. Unit tests go in the source files with the rest of your code under a private submodule (usually conventionally called mod tests). Integration tests go in a separate crate called test completely disjoint from the rest of your code. The former has access to private data in the current module, whereas the latter is forced to interact with it as an independent party.

cargo test runs unit tests first, then integration tests. If you have no unit tests, it will inform you that all 0 of them have passed and then move on to the tests you wrote.

Silvio Mayolo
  • 62,821
  • 6
  • 74
  • 116