Exclude .Tests assemblies in full HTML reports

Exclude .Tests assemblies in full HTML reports

Hello! I want to exclude .Tests assemblies codecoverage from ncover.console generated report but there is only switch for excluding all test assembly. How to do that?


RE: Exclude .Tests assemblies in full HTML reports

Narcomancer,

I think what you're looking for is the //et flag, which will let you specify a regular expression for types to exclude. So, for example, if your tests were all in the Narcomancer.Tests namespace, you could exclude them all with:


//et Narcomancer\.Tests\..*

Alan Johnson NCover Team


RE: Exclude .Tests assemblies in full HTML reports

Hmmm... This did not helped for me. The thing is I don`t want to exclude some namespace. For example: I have project assembly Narcomancer.UI.dll with name namespace Narcomancer.UI. Also I have Narcomancer.Tests.dll which have tests for project code. It contains any existing project namespace as Narcomancer.UI. So the test method will be Narcomancer.UI.FirstTest. For now my NCover report is showing all coverage - Narcomancer.Tests.dll module and Narcomancer.UI.dll module. When I browse throught namespace methods I can find there Narcomancer.UI.FirstTest what is wrong. So I want to exclude all *.Tests.dll assembly (module) from report and have report about all tested project assemblies (Narcomancer.UI). For now test report contains project assemblies coverage + test assemblies coverage so the code coverage summary is wrong.

As I understood I should use //ef '.Tests.' but it is not working for me.

I hope I was clear enough.


RE: Exclude .Tests assemblies in full HTML reports

Narcomancer,

the //ef command is meant to exclude source files, not assemblies. Sorry if that wasn't clear. There should be two ways to do what you're trying to do. The first is to use the //a flag and specify which .dll files you want profiled. The second is to use //et and a regex that will capture all of the classes in the .Tests dll. Something like "//et .Test." should work.

Stephen


RE: Exclude .Tests assemblies in full HTML reports

Yes, now it is working, Thank You. But this is affecting only "Sequence Point Coverage", not "Branch Coverage". Why it is so? Anyway this is not the best solution because I have some filenames in Tests which has some common methods etc, for example ICommonMethods.cs, so they are affected. The only way I see is to rename these files...

I just want to exclude any related coverage to tests itself. On Java platform, for example Clover or Cobertura, this is by default.


RE: Exclude .Tests assemblies in full HTML reports

narcomancer,

The //et flag should exclude branch points from coverage as well. If you have a coverage file where they don't appear to be excluded, you can send the coverage file along with your command line to support@gnoso.com and we'll take a look at it.

The //et flag only excludes classes and namespaces, not source files, so it wouldn't exclude ICommonMethods.cs unless the class in the file has "Test" somewhere in its fully-qualified name (namespace + classname). If ICommonMethods.cs is used by non-test code, then I would assume it is located in a non-test namespace.

Stephen Ward


RE: Exclude .Tests assemblies in full HTML reports

Thats what Im talking about. In this case ICommonMethods.cs is used only from Test code so it should be in tests. I`ll send coverage file where You pointed to.


RE: Exclude .Tests assemblies in full HTML reports

narcomancer,

We've received your coverage file and I'll get back to you as soon as I can. For ICommonMethods.cs you'll either have to move it to a "Tests" namespace, or you can use the "//ef ICommonMethods.cs" flag to exclude the entire file from coverage.

Stephen