How to use sonar.cs.msbuild.testProjectPattern

959 views Asked by At

I've read some questions which answers mention that sonar.cs.msbuild.testProjectPattern is used by SonarQube to skip code analysis for Projects that match the pattern.

Currently I have a big solution which one of it's projects contains "UnitTesting" as part of it's Name and also as part of the physical path.

Example:

The project name is something like "Something.MoreText.UnitTesting" (with a .csproj file name of "Something.MoreText.UnitTesting.csproj")

The physical path is "C:\Something\Folder\Etc\UnitTesting"

The default pattern is [^\]test[^\]$ which enforces 'test' being case sensitive.

This project is getting excluded from analysis. I want to make sure I understand the reason why it is getting excluded. Other projects in the same solution are getting analyzed just fine.

I want to understand how the usage of the pattern works. Does the pattern applies to the project name? to the project path in the disk? It is not case sensitive as it seems the default pattern is? Is there another reason my project is being excluded (we haven't added any explicit exclusion keys to the project files)?

Note: I came across this article Detection of Test Projects, there it says

Projects with "test" in their names.

Some answers mention that it is the file path, some that it is the name, some that it is both...

Environment: SonarQube 5.6.1, C# 6 projects. VS 2015 MSBuild 14, SonarQube Scanner for MSBuild 2.2, OpenCover, nUnit 2.3

1

There are 1 answers

0
milbrandt On

The property sonar.cs.msbuild.testProjectPattern has been deprecated in Sonarqube 5.1 and removed in 6.7. See PR 917 at sonar-csharp.

Now Parameter sonar.msbuild.testProjectPattern on the Client side should be used instead.