Aage
Aage

Reputation: 6252

Exclude test code from code metrics

Is it at all possible to exclude Class Libraries or code files from code metrics? I cannot find good resources on this as they all seem to focus on Code Coverage, which can be set in a .runsettings file.

I would like to have a build without warnings on lines-of-code on test projects.

Upvotes: 4

Views: 2124

Answers (2)

Aage
Aage

Reputation: 6252

Apparently, there is a Files to ignore field on the build template, which I haven't noticed for months:

Code Metrics > Files to ignore.

This takes a regular expression, so I can just put:

*.Tests.dll

This excludes my test libraries.

Upvotes: 5

Zwo
Zwo

Reputation: 1113

You have to separate your solution into two projects. One for your program, one for tests. Then you you just have to run code analysis on the program project. And remember that your tests have also to be clean

Upvotes: 0

Related Questions