I am trying to exclude the unit test projects/folders from the code coverage analysis since it is inflating the code coverage percentage.
I have different layers/projects and unit test projects for each of those. As shown below.
Solution
DataAccess
Business
Service
Model
Test.DataAccess
Test.Business
Test.Service
Test.Model
How do I exclude any folder/project that has "Test.*" in its name/path? I want to exclude everything within those folders.
I've tried the patterns below (and many others):
**\*Test.*\*
*Test.*\*
Test.*\*
**/*Test.*/*
*Test.*/*
Test.*/*
I cannot get it to exclude the unit test files. It doesn't seem to recognize wildcards within the directory name.
As @G.Ann-SonarSourceTeam and @Isaiah4110 stated, a better solution was to have sonarQube exclude test projects all together. I'm not sure why this wasn't happening by default in our case but our solution was to add the "SonarQubeTestProject" property to the *.csproj files.
We had a similar issue and I mentioned the file name pattern instead of the folder name to get by. So we had the unit test file names ending with either test.cs or tests.cs. So I added
and it works like a charm!