In .NET should you place unit test projects in with the rest of the solution? Or should there be a test solution that houses all the test projects?
We have all the test projects in with our code base solution...it seems a bit cumbersome.
What do you usually do?
Unit tests often mirror the structure of the code under test. For example, a unit test project would be created for each code project in the product. The test project can be in the same solution as the production code, or it can be in a separate solution. You can have multiple unit test projects in a solution.
Put Unit tests in the same project as the code to achieve better encapsulation. You can easily test internal methods, which means you wont make methods public that should have been internal. Also it's really nice to have the unit tests close to the code you're writing.
In our current project we decided to put all unit tests in separate projects. The application code and tests are in the same solution, but at least we can build (and deploy) a version without the unit test code.
The downside of this -so far- has been that sometimes your unit tests can't reach certain members of the application code (protected and internals), but that usually lead us to discover that our design could be improved.
And I guess I should point out a similar thread Here with more answers on the same/similar topic.
I've always kept them as part of the solution - they are, after all, part of the solution. You can have multiple solutions though for different approaches to viewing your projects, so a testless solution may be what you'd want to create for some cases.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With