Unable to read beyond the end of the stream

Unable to read beyond the end of the stream

Hi,

I'm currently using ncover to perform a fairly large test run (coverage.log file about 30Mb) and I receive the above message at the end of the ncover run. The coverage.log file and the nunitresults.xml file are produced, but no coverage.xml file - Any ideas?

Many Thanks,

Mark


Re: how to exclude untested code from the coverage report?

Yes you can, using the coverage exclusion attribute capability. See question 9 in this NCover FAQ:

http://www.kiwidude.com/dotnet/NCoverFAQ.html

You can apply the attribute at the method or class level. If you want to test those class files in one scenario but not in another I guess you could add some conditional compilation directives around the attributes.


Re: how to exclude untested code from the coverage report?

kiwidude wrote:
If you want to test those class files in one scenario but not in another I guess you could add some conditional compilation directives around the attributes.

Yes, unfortunately that's what we'd like to do.  But conditional compilation would be time-consuming to implement, given the nature of our project.  Thanks for the info though.


Re: how to exclude untested code from the coverage report?

Or, why not create 2 "NoCoverage" attributes.

In Common.Dll code, use the CommonCoverageAttribute. In the common tests, do not specify any attribute to filter out code.

In your 3 other tests, then specify that attribute. With the same code, you then have 2 behavior.

nick


Re: how to exclude untested code from the coverage report?

Good point Nick - in fact surely you only need the one attribute defined, which you markup the code in the class file in Common.dll. Then as you say you only supply it in the //ea arguments to NCover when you are running your main test suite, and not when you are running Common.Tests.dll.

You would only need to define a second attribute if you had a need to exclude some "other" code when Common.Tests.dll was run.


Re: how to exclude untested code from the coverage report?

I can not get this to work. I have defined my attribute as follows:


class CoverageExcludeAttribute : Attribute
{
}

I also tried it within a namespace, with AttributeTargets specified to Method, Class and Constructor.

I then apply the attribute to, for example, this method

       [CoverageExclude]
public void FooBar()
{
int foo;
foo = 4;
}

And run NCover like this

NCover.Console "c:\Program Files\NUnit-Net-2.0 2.2.8\bin\nunit-console.exe" c:\cc\Projects\maticalc\src\MatiCalcSolution\MatiCalcTest\bin\Debug\MatiCalcTest_NUnit.dll //ea CoverageExcludeAttribute //x c:\cc\Projects\maticalc\mergeOutput\coverage.xml

But no matter what I try, FooBar gets included and reported as uncovered code.

I am using NCover version 1.5.7

C:\cc\Environment\ncover>NCover.Console.exe
NCover.Console v1.5.7 - Code Coverage Analysis for .NET - http://ncover.org
Copyright (c) 2004-2006 Peter Waldschmidt

Any help would be appreciated. Thanks.


Re: how to exclude untested code from the coverage report?

Hi there,

It all seems to be working fine for me. Make sure you havent got any old NCover coverlib.dll versions registered on your machine. Here is my test class, with an exclusion attribute outside of any namespaces:

using System;

public class CoverageExcludeAttribute : Attribute { }

namespace NCoverDemo {
    class Program {
        static void Main(string[] args) {
            Foo foo = new Foo();
            Console.WriteLine(foo.Bar);
        }
    }

    class Foo {
        private string bar = "NCover Demo";

        public string Bar {
            get { return
bar; }
            set { _bar = value; }
        }

        public string ExcludedProperty {
            [CoverageExclude]
            get { return "ExcludedProperty"; }
        }

        [CoverageExclude]
        public void ExcludedMethod() {
            Console.WriteLine("ExcludedMethod");
        }
    }

    [CoverageExclude]
    class ExcludedClass {
        public ExcludedClass() {
            Console.WriteLine("ExcludedClass");
        }
    }
}

Create a new Console application called "NCoverDemo".
Paste in the code above into Program.cs.
Build it and bring up a dos prompt in the bin\Debug folder.

For NCover 1.5.7 (latest build off the NCover site released a few days ago) you can do this:

<Path to NCover>\NCover.Console.exe //reg //ea CoverageExcludeAttribute NCoverDemo.exe

This will register/unregister on the fly coverlib.dll and should result in the correct coverage of 75% in NCoverExplorer. The excluded nodes will still appear in the coverage.xml file, but they will have their "excluded" attributes set to true which is what NCoverExplorer or stylesheets can use.