Problem with Filter usage #20
Comments
not knowing the assembly and class names this is hard to guess but the syntax is [assembly_name_filter]namespace_class_filter so for you I would guess it would be -filter:"+[Test.Weather]* -[Test.Weather]*.WeatherEffects" exclusion filters take precedence over inclusion filters |
Hi, Eg. when we set the filter to only include only certain classes in the assembly Similarly when i try to remove certain classes with -[]*.Tests this does not remove those Tests classes. Is there a way to do this,please suggest .Its important as we are in tight deadlines. |
Hi the problem is I don't know the name of you assemblies or namespaces/classes to help you First are you using the latest version? Second could you run the coverage with the filter +[] only i.e. -filter:+[], and post the output on http://www.pastie.org/ that way I can see the report and then let you know what filters I would use. Also are your tests in a different assembly of the same assembly as the code being tested? |
Hi, |
Okay if we use the output from opencover coverage as an example the command line OpenCover.Console.exe -register:user -target:......\tools\NUnit-2.5.9.10348\bin\net-2.0\nunit-console-x86.exe -targetargs:"OpenCover.Test.dll /noshadow" -filter:"+[Open*]* -[OpenCover.T*]*" -output:opencovertests.xml produced the following report (cut down for clarity) but you have access to the source and can build and run the dogfood test <?xml version="1.0" encoding="utf-8"?>
<CoverageSession xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Modules>
<Module>
<FullName>P:\projects\opencover.git\working\main\bin\Debug\OpenCover.Framework.dll</FullName>
<ModuleName>OpenCover.Framework</ModuleName>
<Files>
<File uid="1" fullPath="P:\projects\opencover.git\working\main\OpenCover.Framework\Persistance\BasePersistance.cs" />
<File uid="5" fullPath="P:\projects\opencover.git\working\main\OpenCover.Framework\Persistance\FilePersistance.cs" />
...
<File uid="29" fullPath="P:\projects\opencover.git\working\main\OpenCover.Framework\Communication\MarshalWapper.cs" />
</Files>
<Classes>
<Class>
<FullName><Module></FullName>
<Methods />
</Class>
<Class>
<FullName>OpenCover.Framework.Persistance.BasePersistance</FullName>
<Methods>
<Method cyclomaticComplexity="1">
<MetadataToken>100663313</MetadataToken>
<Name>System.Void OpenCover.Framework.Persistance.BasePersistance::.ctor()</Name>
<FileRef uid="1" />
<SequencePoints>
<SequencePoint ordinal="0" offset="0" sl="10" sc="9" el="10" ec="33" vc="6" uspid="1" />
<SequencePoint ordinal="1" offset="7" sl="11" sc="9" el="11" ec="10" vc="6" uspid="2" />
<SequencePoint ordinal="2" offset="8" sl="12" sc="13" el="12" ec="53" vc="6" uspid="3" />
<SequencePoint ordinal="3" offset="20" sl="13" sc="9" el="13" ec="10" vc="6" uspid="4" />
</SequencePoints>
</Method>
<Methods>
</Class>
...
</Classes>
</Module>
</Modules>
<VisitPoints />
</CoverageSession> Then the assembly_name_filter is matched against //Module/ModuleName and the namespace_class_filter matches against I hope that helps explain the filter PS if data issues are a problem then you can send messages direct via github, though I doubt there is anything of sensitive nature in the reports as all we have are namespace and class names and sequence points (no code or data) |
Ok .I have checked i cannot send the report. But its quite a simple app i tried.I followed you filters example and tried.But didnt work Example: Hello.cs namespace SampleApplication
{
class Hello
{
public void HelloHello()
{
Console.WriteLine("Hello");
}
}
} Another class Calculate.cs same Namespace namespace SampleApplication.Logic
{
class Calculate
{
public void MultiplyResults()
{
Console.WriteLine("Weather is good");
}
public void GetResults()
{
Console.WriteLine("Weather is good");
}
}
} Now to generate the coverage report ,i do not want Hello.cs to be included So here is the filters cmd i use Report Generated Assemblies SampleApplication.Hello 0% SampleApplication.Logic.Calculate 0% SampleApplication.Program 0% SampleApplication.Test1 87.5% SampleApplicationTest.UnitTest1 100% Here it shows coverage of SampleApplication.Hello 0% NOTE: Updated by sawilde to improve markup |
I am assuming you are using the latest version of OpenCover as that has fixes for filters. Based on your details presented above the filter I would use would look something like this As they are in different namespaces -filter:"+[WeatherApp]SampleApplication.Logic.*" if your sample was wrong and Hello and Calculate were in the same namespace -filter:"+[WeatherApp]SampleApplication.Logic.Calculate" or -filter:"+[WeatherApp]SampleApplication.Logic.* -[WeatherApp]SampleApplication.Logic.Hello" NOTE: Please note that GitHub uses markup and so it better to read these posts on the web site were it has been rendered |
Hi, Error: Anetwork error occured while attempting to read from the file C:\Users\Desktop\opencover 1.0.508.msi Anyway i tried the filters with .506 version.Results were the same .But as you mentioned filters are fixed in .508 lib\OpenCover\OpenCover.Console.exe -register:user -target:lib\NUnit\nunit-console.exe -targetargs:"SampleApplication\bin\AnyCPU\WeatherApp.exe /noshadow" -filter:"+[WeatherApp]SampleApplication.* -[WeatherApp]SampleApplication.Logic.Calculate" -output:out\opencover.xml |
Ok..I did uninstall of previous version and then installed the new version 1.0.508. But i get the same results .All classes are in same namespace.(SampleApplication.Hello and SampleApplication.Logic.Calculate) lib\OpenCover\OpenCover.Console.exe -register:user -target:lib\NUnit\nunit-console.exe -targetargs:"SampleApplication\bin\AnyCPU\WeatherApp.exe /noshadow" -filter:"+[WeatherApp]SampleApplication.* -[WeatherApp]SampleApplication.Hello" -output:out\opencover.xml Assemblies SampleApplication.Hello 0% SampleApplication.Logic.Calculate 0% SampleApplication.Program 0% SampleApplication.Test1 87.5% SampleApplicationTest.UnitTest1 0% |
I see the problem now, sorry for the confusion. The issue is that filtered classes are still in the report when they should not be - though they are being left uninstrumented and as such the report looks worse than expected. I'll sort it as soon as |
Uploaded a new version - please let me know if it solves your issue |
It would appear you think the new version fixes this issue see #10 |
Hi,
class filterers on assemblies does not work for OpenCover.
eg : OpenCover.Console.exe -target:$(NUnit-ToolPath)\nunit-console.exe -targetargs:"/noshadow \path.dll
-filter:"+[Test.Weather]* -[*.WeatherEffects]" -output:Test.xml
Now when generating report i need to remove all WeatherEffects class coverage.But the filter does not work.Could you suggest if syntax is ok.
NOTE: Issue originally raised by https://github.com/guptkan as a comment to issue #16
The text was updated successfully, but these errors were encountered: