I know this is a very old question, but I would like to add my experience there I recently change unit testing habit from separate projects to same one.
Why?
First I am very tend to keep main project folder structure same with test project. So, if I have a file under Providers > DataProvider > SqlDataProvider.cs
then I am creating same structure in my unit test projects like Providers > DataProvider > SqlDataProvider.Tests.cs
But after project is getting bigger and bigger, once you move files around from one folder to another, or from one project to another, then it is getting very cumbersome work to sync those up with unit test projects.
Second, it is not always very easy to navigate from class to be tested to unit test class. This is even harder for JavaScript and Python.
Recently, I started to practice that, every single file I created (for example SqlDataProvider.cs
) I am creating another file with Test suffix, like SqlDataProvider.Tests.cs
At the beginning it seems it will bloat up files and library references, but at long term, you will eliminate moving file syndrome at first glance, and also you will make sure, every single file those are candidates of being tested will have a pair file with .Tests
suffix. It gives you easy of jumping into test file (because it is side by side) instead of looking through separate project.
You can even write business rules to scan through project and identify class which does not have .Tests file, and report them to the owner. Also you can tell your test runner easily to target .Tests
classes.
Especially for Js and Python you will not need to import your references from different path, you can simply use same path of target file being tested.
I am using this practice for a while, and I think it is very reasonable trade-off between project size vs maintainability and learning curve for new comers to the project.