Should I put unit testing stuffs in a separate repository, not in the same repository as the programming library? So I reference the programming library as submodule. But most open source projects that I have seen do not organize the projects like what I mention above. Can anyone explain which approach is better?


2 Answers 2


You should put the unit tests in the same repository because otherwise someone has to answer to the question "Where are the tests?" every time the project is handed over from one person to another. References to other repositories tend to get invalid over time when repositories are relocated and people change from one version control system to another.

Just keep the tests close to the code.

  • In Visual Studio, the tests are kept in a separate project, but the test classes are named in such a way that they can be correlated to the classes under test. Commented Nov 8, 2012 at 7:14
  • 7
    @RobertHarvey: one should also note that Visual Studio uses two terms: solution (which is similar to what is called a project outside Microsoft world) and project. A solution is the product itself and corresponds, most of the time, to a single repository. A project is a part of the solution and usually produces a DLL, an executable, a Silverlight application, etc. Commented Nov 8, 2012 at 8:02
  • 3
    @RobertHarvey different project, but same solution and same repository usually. I don't think this is very different to any other platform. you do not usually put your test code in the production executable.
    – jk.
    Commented Nov 8, 2012 at 8:03
  • 3
    One special case is a test data repository. If you have large data files that are used by your test suite, it can be helpful to put them in their own repository to speed up checkouts and avoid memory problems with the revision control system. This is especially useful if the datasets change slowly compared to the code. I suspect this may be more common in scientific programming than in other domains. Commented Nov 8, 2012 at 21:56

You want the version of the tests to match the version of the code, so that implies you keep the tests in the same repository as the code. That goes for automatic code generation scripts, build scripts, etc. too.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.