NCover v1.5.4 reports wrong coverage results - 100% but it's

NCover v1.5.4 reports wrong coverage results - 100% but it's

Hi there,

if I execute the following code I will get 100% coverage, but only the class CoveredClass was visited at all. Test1.NotCoveredClass and Test2.NotCoveredClass were not covered which should result in approx. 33% total coverage

namespace Test1
{
    class CoveredClass
    {
        public void test()
        {
            Console.WriteLine("Test1.Foo.test");
        }
    }

    class NotCoveredClass
    {
        public void test()
        {
            Console.WriteLine("Test1.Foo2.test");
        }
    }

    class Program
    {
        static void Main(string[] args)
        {
            CoveredClass f = new CoveredClass();
            f.test();
        }
    }
}

namespace Test2
{
    public class NotCoveredClass
    {
        public void test()
        {
            Console.WriteLine("Test2.Foo.test");
        }
    }
}

If classes not covered are part of an assembly this will result in wrong coverage at all. If a class is not covered at all it should be reported as 0%.

I've executed this simple test in debug mode within optimization on .Net 2.0 and run NCover v.1.5.4.

Ciao
Thomas


Re: Coverage problem with TestDriven and NCover

As long as you are not trying to get coverage on the XNA assemblies themselves, it shouldn't matter whether they have PDB's or not.  I've never tried to run with XNA studio before.  There may be some non-standard stuff going on there since it's intended for a game platform.  Is there a good way for me to test it out for myself without going through the game developer registration process?


Re: Coverage problem with TestDriven and NCover

You shouldn't need to register for anything, you just need Visual C# Express and XNA Game Studio Express 1.0 Refresh.  Installing VC# Express side-by-side with any other SKU is safe, once you install GSE you don't necessarily need to use VC# Express, though I do believe that the GSE installer is dependent on VC# Express being installed.


Re: Coverage problem with TestDriven and NCover

I just tried your sample. Running it with NCover 1.5.8 gives the "index outside the bounds of the array" exception which has been reported elsewhere on these forums. Do you not get similar output in your output window in the IDE?

I appreciate it doesnt help you resolve the problem for now but the repro case ensures the issue can be fixed for NCover 2.0. The only solution to the index out of range exception for now until the new release comes out is to go back to an earlier NCover version such as 1.5.4 or 1.5.5.


Re: Coverage problem with TestDriven and NCover

Just to add to this...

I believe the reason why you get different behaviour between the two tests is that with the test commented out the XNA framework assemblies are not required to be loaded into memory. My belief in what is tripping NCover up is something about the contents of the msvcm80.dll which it is attempting to profile. If you look in the coverage.log file you can see that it does get "Loaded" so NCover will attempt to profile it.

In fact, if you run NCover.Console using the //a argument to specifically just include the application dll(s), then the coverage works fine for me - how about you? Try something like this:

"E:\Apps\NCover\1.5.8\NCover.Console.exe" //reg //w "E:\Dev\2005\GameTest\bin\x86\Debug" //x "Coverage158.xml" //a GameTest "C:\Program Files\NUnit 2.4.2\bin\nunit-console.exe" GameTest.dll

I do find this a little intriguing as I thought Jamie was doing the //a trick already in TD.Net so it should give the same results when you do Test with Coverage. Will ask him about that at some point...

As for the actual cause of the Index Out of Bounds exception - it is to do with some code in NCover.Console 1.5.7/1.5.8 trying to reconcile the sequence points it has found prior to writing out the coverage.xml file. If some "dodgy" results come back from the profiler portion in terms of sequence points then unfortunately the reconciling code doesnt handle it gracefully. Both the profiling and the post profiling processing code have been significantly upgraded as part of NCover 2.0 (available soon) and it profiles your example successfully according to my testing with it.


Re: NCover and No-Touch .Net deployed application ...

There's a bunch of threads around if you look through the forums. The answer is you need to regsvr32 coverlib.dll (for NCover 1.5.5 and earlier).