Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tests Projects In Solution

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?

like image 335
Adam Driscoll Avatar asked Nov 06 '08 18:11

Adam Driscoll


People also ask

What is unit test project?

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.

Should unit tests be in the same project?

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.


2 Answers

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.

like image 66
FOR Avatar answered Sep 24 '22 01:09

FOR


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.

like image 20
cfeduke Avatar answered Sep 22 '22 01:09

cfeduke