• 0 Posts
  • 1 Comment
Joined 1 year ago
cake
Cake day: June 14th, 2023

help-circle
  • For unit tests, I put them within a folder parallel to the source code. The directory in that folder matches the module hierarchy.

    A flat structure can work for extremely small projects, but things start to go sideways as the code base grows.

    Putting the test files alongside the source files makes it harder work with from a project management perspective:

    • pytest has to check more files when doing discovery, which makes the tests take longer
    • It is significantly harder to configure mypy to a more lenient set of rules for test code.
    • It is harder to package/deploy only the runtime code

    If the project is big enough to have integration tests, I prefer to have those in their own folder like the unit test folder. It is possible to mark tests into different categories, but putting them in a dedicated folder makes it is harder for people to forget to mark an integration test.