Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

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?

share|improve this question
They are going to put unit tests in a separate repository !!! github.com/gitextensions/gitextensions/pull/1470 –  linquize Dec 12 '12 at 1:28

3 Answers 3

up vote 18 down vote accepted

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.

share|improve this answer
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. –  Robert Harvey Nov 8 '12 at 7:14
@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. –  MainMa Nov 8 '12 at 8:02
@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. Nov 8 '12 at 8:03
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. –  Stephan A. Terre Nov 8 '12 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.

share|improve this answer

One advantage of storing tests in a separate repository is if tests developers should be granted read-only permissions to the tested code, and read/write permissions to the tests.

share|improve this answer
I fail to see this as an advantage, because the developers responsible for a piece of code should also be responsible for the tests covering that piece of code. –  Pete Jun 24 at 8:00
@Pete, true, for unit tests, not necessarily for application / integration tests. –  Ben-Uri Jun 24 at 11:57

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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