Where do your unit tests live? Does is vary, depending on project size? Do you like a flat structure, with test files living alongside everything else? Are you a nested folders person?

I’m curious the practice of others, because I still don’t feel like I’ve found a testing directory structure that satisfies me.

  • Willem@kutsuya.dev
    link
    fedilink
    English
    arrow-up
    6
    ·
    1 year ago

    For unit tests I usually have a test/ folder next to my src/ folder, that duplicates the folder structure. My brain prefers things being seperate from eachother (resources, source code per language, tests) and this is afaik the only way that you can keep it consistent between different languages (C# for example needs a seperate unit test project)

    • im_orange@discuss.tchncs.de
      link
      fedilink
      English
      arrow-up
      6
      arrow-down
      1
      ·
      1 year ago

      In Rust, the tests usually sit right next to the source code, even in the same file. That’s partly because the compiler can just strip the tests from the final binary, and I assume partly just conventional. In Python, you usually want to keep the tests out of the final sdist/wheel, so the setup you described is probably the most common in bigger projects.