BenMorris / NetArchTest

A fluent API for .Net that can enforce architectural rules in unit tests.
MIT License
1.39k stars 82 forks source link

[Question] Can NetArchTest be used to enforce creation of a test class for every class in a project? #104

Closed devantler closed 2 years ago

devantler commented 2 years ago

Can this tool be used to enforce creation of unit test classes, and enforce their paths so e.g. a project with the following classes:

src/MyProject/Main.cs
src/MyProject/AFolder/AClass.cs

... would require an accompanying test project with the following classes:

tests/MyProject.Tests/Main.cs
tests/MyProject.Tests/AFolder/AClass.cs
BenMorris commented 2 years ago

I suppose we could add some kind of pattern matching method, e.g.

var result = Types
    .That()
    .ResideInNamespace("Example")
    .Should()
    .HaveMatchingClass([some kind of funky regular expression])
    .GetResult();

However, I am not sure how useful this would be. After all, ensuring a test class is created for each functional class is no guarantee of a meaningful unit test suite. I would be more inclined to use a test coverage tool like SonarQube for managing test coverage.