Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.NET Testing Naming Conventions [closed]

Tags:

What are the best conventions of naming testing-assemblies in .NET (or any other language or platform)?

What I'm mainly split between are these options (please provide others!):

  • Company.Website - the project
  • Company.Website.Tests

or

  • Company.Website
  • Company.WebsiteTests

The problem with the first solution is that it looks like .Tests are a sub-namespace to the site, while they really are more parallel in my mind. What happens when a new sub-namespace comes into play, like Company.Website.Controls, where should I put the tests for that namespace, for instance?

Maybe it should even be: Tests.Company.Website and Tests.Company.Website.Controls, and so on.

like image 904
Seb Nilsson Avatar asked Sep 17 '08 15:09

Seb Nilsson


People also ask

What is an appropriate naming scheme for a test class?

Test class naming convention usually follows the naming convention of the class being tested, e.g., the class under test is “Order” the corresponding test class will be “OrderTests“. When in doubt, it is a good practice to model the test class name after the production class it is testing.

What should I name unit test file?

The name of your test should consist of three parts: The name of the method being tested. The scenario under which it's being tested. The expected behavior when the scenario is invoked.

Which is better NUnit or MsTest?

The main difference is the ability of MsTest to execute in parallel at the method level. Also, the tight integration of MsTest with Visual Studio provides advantages in both speed and robustness when compared to NUnit. As a result, I recommend MsTest.


2 Answers

I will go with

* Company.Website - the project * Company.Website.Tests 

The short reason and answer is simple, testing and project are linked in code, therefore it should share namespace.

If you want splitting of code and testing in a solution you have that option anyway. e.g. you can set up a solution with

-Code Folder

  • Company.Website

-Tests Folder

  • Company.Website.Tests
like image 122
Claus Thomsen Avatar answered Oct 05 '22 16:10

Claus Thomsen


I personally would go with

Company.Tests.Website

That way you have a common tests namespace and projects inside it, following the same structure as the actual project.

like image 34
Mitchel Sellers Avatar answered Oct 05 '22 16:10

Mitchel Sellers