Giter Club home page Giter Club logo

Comments (4)

k0pernicus avatar k0pernicus commented on June 2, 2024

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/.

from snatch.

k0pernicus avatar k0pernicus commented on June 2, 2024

The directory tests/ has been created by @Jean-Serge - merged with commit 74ff12e

from snatch.

k0pernicus avatar k0pernicus commented on June 2, 2024

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.

from snatch.

Jean-Serge avatar Jean-Serge commented on June 2, 2024

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.

from snatch.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.