1.5.2 exclusion feature

1.5.2 exclusion feature

Maybe I'm doing something stupid, but I can't get the attribute based coverage exclusion to work in this release.

I've created a new attribute type like so (in vb.net, not my choice for this project...)

    <AttributeUsage(AttributeTargets.All)> _
    Public Class NCoverIgnoreAttribute
        Inherits Attribute

    End Class

I then applied this attribute to a series of classes (that also have other attributes on them if that matters), that I wanted excluded from the coverage report.

I then added //ea BusinessLayer.NCoverIgnoreAttribute to my command line arguments for NCover.

They get processed the way they normally do.

What am I missing?


Re: NCover does not detect all coverage correctly

You havent given much info to go on here. Define "part" - methods missing from a profiled assembly, or an entire assembly missing? What version of NCover/.Net? How are you running NCover?

Assemblies will be missing for these reasons: (1) There is no .pdb, (2) No types are being loaded from them during the execution or (3) they have been excluded as you are using the //a argument listing spefiic assemblies not including those ones.

Also generics can cause a problem for NCover - something which I know Peter is working on addressing.


Re: NCover does not detect all coverage correctly

I have the following sourcecode:

protected virtual void DoItemAdded(T item) {
            if (mItemAdded != null) {
                mItemAdded(this, item); // this line isn't executed.
            }
            if (mItemAddedBase != null) {
                mItemAddedBase(this, item);
            }
        }

I have added 2 different methods to the events, and it turns out they are being executed.

Regards,

Matthijs ter Woord


Re: NCover does not detect all coverage correctly

I'm running NCover 1.5.5 for a .Net 2.0 project called from Visual Studio 2005 Professional on Windows XP SP2

When I run the coverage tool from the VS Plugin, my code coverage unreports.  From NCover Explorer, the highlighting indicates that lines which are being executed, have not.

For example:

Console.writeln("This is a test") ; //Executed

if (isTrue() == true) { //Not executed
...

I'd think the following scenario should be impossible.

Also, closing braces are never reported as executed; making it impossible to have 100% coverage

When I revert to NCover 1.5.4, coverage reports as I expect.



Re: NCover does not detect all coverage correctly

If you look through the forums you will see dozens of scenarios people have hit problems with using NCover 1.5.5. Hence my stock standard recommendation to not touch it with a barge pole and use 1.5.4 instead until 1.5.7 is release. NCover 1.5.4 does have its own problems of course but they are not as likely to produce corrupted coverage results.

Roll on 1.5.7 - hopefully Peter gets a chance to finish it off soon...


Re: NCover reports incorrect coverage for multiple assembles via

Exactly which version of NCover are you using?

Have you tried putting quotes around the list of assemblies (i.e. the "arguments" to NUnit)?
i.e. "TestA.dll TestB.dll TestC.dll"

Regards,
Grant
http://www.kiwidude.com/blog/


Re: NCover reports incorrect coverage for multiple assembles via

    That's funny.. that was the thing that popped in my head while I was writing up that post. I will try that at home today...

I don't think that it's the problem, since I can verify all the tests from the 3 DLLs run from the nunit console output. It's just the Coverage that's missing.


Re: NCover reports incorrect coverage for multiple assembles via

I think I should listen to myself more often... Turned out to be quotes after all
Here's my observation set....

>L:\BuildFolder\AT_Bin\debug>l:\Tools\NCover\NCover.Console.exe /c "l:\Program Files\NUnit_227\bin\nunit-console.exe" TestParts.dll TestPartsGUI.dll GTestHelpers.dll

This will profile code exercised by tests in TestParts.dll. Is it a NUnit thing ?

 >"l:\Program Files\NUnit_227\bin\nunit-console.exe" GTestHelpers.dll TestParts.dll TestPartsGUI.dll

No that runs all 40 tests. Turns out I need to add ‘quotation marks’ for NCover.

>L:\BuildFolder\AT_Bin\debug>l:\Tools\NCover\NCover.Console.exe /a Parts;PartsGUI;GTestHelpers /c "l:\Program Files\NUnit_227\bin\nunit-console.exe" TestParts.dll TestPartsGUI.dll GTestHelpers.dll

And that's a wrap !!!


Re: NCover reports incorrect coverage for multiple assembles via

Always glad when there is a reason ;-)

The command line can be a right ar*e to get right - a pretty high percentage of the questions for NCover on these forums come from issues with it. Either its quotes for the profiled process arguments, paths with spaces (i.e. more missing quotes), too much information (paths or suffixes in the assembly names for /a) or wrong working directory specified.

I have asked Peter to update his FAQ when he finds a spare moment to hopefully help people out a little more. I too have had my battles with it in the past... of course nowadays I use my NAnt and MSBuild tasks on the build servers, or TestDriven.Net on the developer machines so only resort to it when helping someone out on the forums ;-)

Regards,
Grant.
http://www.kiwidude.com/blog/