Unit tests integrations
k0pernicus opened this issue · 4 comments
The project needs some unit tests - each new feature has to be tested.
Also, I think that the better solution to test each function/feature is to add unit testing in the documentation of the function, and in a custom file in tests/
.
The directory tests/
has been created by @Jean-Serge - merged with commit 74ff12e
The current solution to test private functions/methods is to add the test module inside the source file that contains those private ones.
Example:
// src/my_mod.rs
/// A private function that returns an Option type
fn my_private_function() -> Option<usize> {
...
}
#[cfg(test)]
mod my_private_tests {
use super::my_private_function;
/// A function to test my_private_function()
fn test_my_private_function() {
...
}
}
However, a good practice is to test public functions/methods in a single test unit file, in the tests/
directory.
Resulting in putting unit tests into the module source file and integration tests into the tests directory.
That way, users could find easily how to use Snatch as a library.