I currently use the following naming scheme for my unit test projects.. if I have a project "MyApp", I will have..

-- MyApp
-- MyApp.Tests

I see this is quite a common practice.

Now, the problem is, if I then have another project MyApp.Common. Now in solution explorer, my projects are sorted

-- MyApp
-- MyApp.Common
-- MyApp.Common.Tests
-- MyApp.Tests

So my MyApp.Tests is no longer "next to" the main project it is testing. As the projects grow, the tests can become mix up all over the place,

I know it is not a big thing, but just wondering if anyone else has encountered this, and thought of any other way?

Thanks in advance for any suggestions.

closed as primarily opinion-based by gnat, Bart van Ingen Schenau, Robert Harvey, BobDalgleish, Greg Burghardt Nov 26 '18 at 19:31

Many good questions generate some degree of opinion based on expert experience, but answers to this question will tend to be almost entirely based on opinions, rather than facts, references, or specific expertise. If this question can be reworded to fit the rules in the help center, please edit the question.


Forgetting the sorting issue for a moment, [ProjectName].Tests is the better naming scheme. It clearly indicates which project the tests belong to, and it follow the general naming approach of subdomain naming.

But as you point out, this does lead to a bit of a sorting issue when you test both a particular domain and its subdomains.

So far, I have resolved this by simply using project folders in the solution.

MyApp (sln)
  - Api (folder)
      - MyApp.Api (csproj)
      - MyApp.Api.Tests (csproj)
  - Business (folder)
      - MyApp.Business (csproj)
      - MyApp.Business.Tests (csproj)
  - Database (folder)
      - MyApp.Database (csproj)
      - MyApp.Database.Tests (csproj)

This may be too cumbersome for excessively large solutions, but I haven't really had experience with >15 project solutions.

The benefit of doing this is that you retain the better naming scheme instead of cleverly renaming things to fit the ordering (but then lose out on the naming conventions).

  • Solution folders are a useful feature as you say. I'd personally just have src and test folders though, rather than your layout. But that's pure opinion of course. – David Arno Nov 22 '18 at 9:24
  • Good suggestion, I had thought about the folders, but find it cleaner (at this stage of my project), to keep the solution "flatter". – peterc Nov 22 '18 at 10:48

Keep the project naming consistent. ie have both naming parts in each project.

It's tempting to omit the second part for the application layer, but aside from the ordering it becomes problematic when you have multiple implementations of the application. eg:


It might seem odd if you just have the one implementation. Or even when you have more than one, but each has its own solution.

But remember these names get used outside of the solution in CI systems, Bug reporting and package managers etc. It's nice to have the same name running all the way through

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