Get more detailed coverage for conditional expressions.

Get more detailed coverage for conditional expressions.

Thanks for NCover - I have just started using it yesterday and it is great.

I wonder if it was possible to get a more detailed coverage for some kinds of conditional expressions.
For example:

    if (condition1 || condition2) ...

If condition1 is always true, condition2 will never be evaluated, but I cannot see this from the coverage report, since the whole line is treated as one unit. Further examples:

    bool b = condition1 || condition2;
    double d = condition ? expr1 : expr2;



Re: Get more detailed coverage for conditional expressions.

This partly depends on the compiler.  I am relying on the C# compiler to tell me (by way of sequence points) what the breakout of the code is.  If the compiler can break out the expressions in the debugger then I should be able to show it in coverage.  Did you check the XML file to see if the data is in the XML?


Re: Profiled process terminated. Profiler connection not establi

I forgot to mention that I am using NCover 1.5. Beta 1 and .NET 2.0 RTM.

cheers

Gawel


Re: Profiled process terminated. Profiler connection not establi

I am experiencing this as well under Win2003, .NET 2.0 RTM and NCover 1.5.0 beta 1 and 1.5.1 beta 2.

If I run it from the command prompt, it works fine, however if I run it under CruiseControl.NET, I get the "Profiled process terminated. Profiler connection not established" message.

Is there some form of additional privilege the cruisecontrol processes may require?

If I look in the 'build log' in CruiseControl, I see the beginning of the output from NUnit (a lot of "."'s, one for each test, and then several console.writes, at which point it fails and I get the message.


Re: Profiled process terminated. Profiler connection not establi

What about the coverage.log file?  Is there anything interesting in that file, especially near the end?


Re: Profiled process terminated. Profiler connection not establi

I had to fall back to 1.33 for right now on the build server, so the 1.5 coverage.log got overwritten.

I'll run an experiment tomorrow and let you know the results.


Resposta: Re: Profiled process terminated. Profiler connecti

I have the same problem, using the ncover 1.5.1 and windows 2003 with cruise control.

In my tests, no file could be create, no even the Coverage.Log

I´m thinking about CruiseControl redirect the output file to XmlLogger, and not to disk, because if I run the same nant build file direct from console the ncover works perfects


Re: Profiled process terminated. Profiler connection not establi

After playing around with NCover 1.5.1 beta 2 I was seeing the "Profiled process terminated. Profiler connection not established." error when running under a limited user account.  The account was a member of Debugger Users, but that was all.  There was no Coverage.log file being produced, and after a minute or so NCover would fail with the "Profiler Connection not established" error message.  In order to get NCover to work under this account I had to do the following:

Set account's registry permissions

Key:

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment

Permissions:

Query Value
Set Value
Create Subkey
Enum Subkeys
Notify
Read Control

Re-register the CoverLib COM component

Run "regsvr32 coverlib.dll" from the directory where NCover is installed.  This will need to be run from an administrator account.

I tried re-registering coverlib.dll since the COM registry entries seemed to only exist in HKCU for the Administrator's account rather than in HKLM.

I'm guessing that the installer only installs NCover for the current user (i.e. Administrator) rather than for all users, but I could be totally wrong.


Re: Profiled process terminated. Profiler connection not establi

This bug is a result of the service profiling code.  I have fixed it in the upcoming release (1.5.2).


Re: Profiled process terminated. Profiler connection not establi

Ops... I have installed the new 1.5.2 and it don´t solve the problem. The message is the same: "Profiled process terminated. Profiler connection not established."


Re: Profiled process terminated. Profiler connection not establi

Indeed, the newest version (released today) has the same issues for me still.

It's not creating any files that I can see, is there anything I can do to help troubleshoot this?


Re: Profiled process terminated. Profiler connection not establi

I can verify that Matt Ward's instructions above indeed work.


Re: Profiled process terminated. Profiler connection not establi

Maybe it's the registration that is the problem.  I'll look into that.


Re: Profiled process terminated. Profiler connection not establi

Between the "Limited User" fix and the "sub-process hang" fix, I think we have this covered in 1.5.3.  If you are still experiencing this problem with 1.5.3 please let me know.


Re: Profiled process terminated. Profiler connection not establi

I am seeing this error message with version 1.5.4 on Windows XP x64, while exactly the same commands cause no problem on my old 32-bit workstation. I've checked that CoverLib.dll is registered, and I also temporarily modified the permissions on the Environment registry key, to no effect.


Re: Profiled process terminated. Profiler connection not establi

I have seen the exact same problem with 1.5.4 on Windows XP x64 Pro. On WinXP 32-bit it works great. I believe I have even tried some of the other versions to no avail, but it has been awhile. Anyone know what this is about?


Re: Profiled process terminated. Profiler connection not establi

I believe this is a bug in NCover, but there is a workaround. I found that it was possible to get NCover to work by forcing it to run as 32-bit. Though they're not NCover-specific, these articles show how to do that using corflags.exe:

Tim Anderson's ITWriting: .NET 64-bit hassles

Wandering through the Wilderness: Platform type observations


Re: Profiled process terminated. Profiler connection not establi

I'm running NCover 1.5.4 and get the same problem. The task works when I run it from the command line but I have no idea what the problem is.

I have my NAnt and NCover setup in tools directories below the root where the project exists and everything is pulled out of source control so nothing is pathed.

Here's my NAnt task to run coverage:

<target name="coverage" description="Generate code coverage using NCover" depends="test">
    <ncover program="Tools\NCover\NCover.Console.exe"
        commandLineExe="Tools\NUnit\nunit-console.exe"
        commandLineArgs="bin\EHT.Tests.Unit.dll"></ncover>
</target>

I'm using the ncover task and it works fine, but I've also tried just an exec task as well. Same error.

Here's the ouptut from Cruise:

coverage:

[exec] Starting 'D:\ccnet\projects\EHT\tools\NCover\ncover.console.exe ( .\\tools\NUnit\nunit-console.exe .\\bin\\EHT.Tests.Unit.dll //a .\\bin\\EHT.Tests.Unit.dll)' in 'D:\ccnet\projects\EHT'
[exec] NCover.Console v1.5.4 - Code Coverage Analysis for .NET - http://ncover.org
[exec] Copyright (c) 2004-2005 Peter Waldschmidt
[exec] Command: .\\tools\NUnit\nunit-console.exe
[exec] Command Args: .\\bin\\EHT.Tests.Unit.dll
[exec] Working Directory:
[exec] Assemblies: .\\bin\\EHT.Tests.Unit.dll
[exec] Coverage Xml: Coverage.Xml
[exec] Coverage Log: Coverage.Log
[exec] Waiting for profiled application to connect...
[exec] NUnit version 2.2.9
[exec] Copyright (C) 2002-2003 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole.
[exec] Copyright (C) 2000-2003 Philip Craig.
[exec] All Rights Reserved.
[exec] OS Version: Microsoft Windows NT 5.2.3790 Service Pack 1 .NET Version: 2.0.50727.42
[exec] ........................................................................................................................................................
[exec] Tests run: 152, Failures: 0, Not run: 0, Time: 3.437 seconds
[exec] Profiled process terminated. Profiler connection not established.

Build Error: NAnt.Core.BuildException
External Program Failed: D:\ccnet\projects\EHT\tools\NCover\ncover.console.exe (return code was 1)
in D:\ccnet\projects\EHT\EHT.build line: 318 col: 6

   at NAnt.Core.Tasks.ExternalProgramBase.ExecuteTask()
   at NAnt.Core.Tasks.ExecTask.ExecuteTask()
   at NAnt.Core.Task.Execute()
   at NAnt.Core.Target.Execute()
   at NAnt.Core.Project.Execute(String targetName, Boolean forceDependencies)
   at NAnt.Core.Project.Execute()
   at NAnt.Core.Project.Run()

I'm running this on a 32-bit Win 2003 server but works on my 32-bit WinXP box as well. I can also run it on the server if I run it by remoting in. The account that CC.NET uses is a local admin (I think) but I can check that.


Re: Profiled process terminated. Profiler connection not establi

bsimser wrote:

Here's my NAnt task to run coverage:

<target name="coverage" description="Generate code coverage using NCover" depends="test">
    <ncover program="Tools\NCover\NCover.Console.exe"
        commandLineExe="Tools\NUnit\nunit-console.exe"
        commandLineArgs="bin\EHT.Tests.Unit.dll"></ncover>
</target>



I was running ncover the same way (using the ncover NAnt task and passing 'tools\NCover\NCover.Console.exe') and had the same problem as you -


[exec] Profiled process terminated. Profiler connection not established.


I worked out that the reason that it is occurring is that the ncover nant task is registering the CoverLib.dll with the same relative path - i.e. 'Tools\NCover\CoverLib.dll' instead of the absolute path to the dll.

To fix it, i changed my nant script to specify

program="${path::get-full-path('tools\NCover\NCover.Console.exe')}"


And it now works fine.

cheers,
Paul.


Re: Profiled process terminated. Profiler connection not establi

NCover is not currently supported on 64-bit Windows platforms. It may run in 32-bit mode, but will not work with a program that is running in 64-bit mode.


Re: Profiled process terminated. Profiler connection not establi

Paul/BSimser

You obviously have your workaround for now to specify a full path for this particular case but it was an oversight in the <ncover> task that it did not support relative paths. I have just fixed this for both the NAnt and MSBuild tasks with the 1.3.6.15 build of the NCoverExplorer.Extras.zip file, available for download from here:

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


Re: Old forum can be found here

I added a link to the main forums page.


Re: expose total Sequence point number

Hi Borys,

I'm sorry but I'm confused about what it is you after after. You have shown above the xml as it is written into the xml file currently. The "sequencePoints" attribute is the total number of sequence points at that particular node level totalling all the children.

Can you please explain again about what extra information you would like to see? Perhaps an example of how you would like the xml enhanced would help too.


Re: expose total Sequence point number

Hi!

Sorry for dim explanation. There are two attributes discribing node: unvisited sequence points(unvisitedPoints) and total sequence points w/o excluded(sequencePoints):

<modules>

<module name="Acadre.CM.Module.DLL" sequencePoints="1376" unvisitedPoints="1034" coverage="24.85465" acceptable="60">

<namespace name="Acadre.CM.Module" sequencePoints="12" unvisitedPoints="12" coverage="0" />

<namespace name="Acadre.CM.Module.Controllers" sequencePoints="181" unvisitedPoints="126" coverage="30.38674" />

<namespace name="Acadre.CM.Module.Properties" sequencePoints="167" unvisitedPoints="96" coverage="42.51497" />

I would like to see something like this:

<modules>

<module name="Infrastructure.Interface.DLL" totalSeqPoints="711" sequencePoints="491" unvisitedPoints="473" coverage="3.66598773" acceptable="60">

<namespace name="Acadre.Infrastructure.Interface" totalSeqPoints="127" sequencePoints="13" unvisitedPoints="13" coverage="0" />

<namespace name="Acadre.Infrastructure.Interface.Commands" totalSeqPoints="283" sequencePoints="202" unvisitedPoints="202" coverage="0" />

Attribute totalSeqPoints mean how many seqPts has each project, module or namespace. In example above I can clearly see that module has 711 seq points, 491 should be covered, 473 not covered. All other necessary information can be measured easily: 711 - 491 = 220 are excluded, 491-473 = 18 is covered which corresponds to coverage 3.66%

This extra value is necessary for getting very important report for my project, which extends yours with total sequence points column. In one report I will be able to see what code (precisely to namespace) was created/removed and how it was covered. I'm build engineer in a big project, which will be significantly extended (2x people in nearest month) and this report might be crusial for us.

Thank you for advance! And hope for future collaboration.

P.S. Would you like to see screenshot of the report on my CCNet?


Re: expose total Sequence point number

Hi Borys, thanks for the detailed explanation.

As I understand it in summary then you want a new node which is the total of all sequence points at that level including "excluded" ones.

I won't know for sure until I trawl back through the code again before I tell you how hard or easy this might be...Just thinking out loud about how it would work. If you had this in the coverage tree:

Namespace.A
+--Class.A (20 seq pts)
+--Class.B (10 seq pts)
+--{Excluded}
      +--Class.C (5 seq pts)

So instead of this:
<namespace name="Namespace.A" sequencePoints="30" unvisitedPoints="xxx" coverage="yyy" />

You want to see this:
<namespace name="Namespace.A" totalSeqPoints="35" sequencePoints="30" unvisitedPoints="xxx" coverage="yyy" />

You wouldnt of course be able to see the details of where those "excluded" 5 sequence points were since Class.C will not get included in the report. You would however as you say be able to report that 5 were excluded at Namespace.A level.

Anything I have missed about this?

A screenshot of your report sounds great mate - always interested to hear about people using NCoverExplorer. Of course if I do find a way to relatively easily implement this then I may just have to steal the idea as a standard report in NCoverExplorer. Feel free to email the screenshot to me if you dont want to put it in the forum.


Re: expose total Sequence point number

Hi, kiwidude!

You've understood me correctly. I don't care about UI in NCoverExplorer: it's a secondary issue to have total sequence points value there.  I would like to have values in xml summary file above all.

I have no permission to upload files on your forum, you are welcome to publish either scheme and screenshot when you will get them


Re: Start NCover Shortcut

Hi Thomas,

The reason I didn't use Ctrl+N is that I had already "nicked" that in the 1.3.4 release for "Next unvisited class in the current namespace", with unmodified N being for "Next unvisited line in the current class".

The full list of shortcuts can be found here in Q12 of the FAQ:
http://www.kiwidude.com/dotnet/NCoverExplorerFAQ.html

I guess one option would be to change the next/previous keys to something else like "[" and "]" (with ctrl [ and  ]) - hence leaving the NCover functionality at the intuitive Ctrl+N... Or I could use modifier keys on the arrows a bit like Lutz in Reflector (alt-left/right arrow for next/previous unvisited line, and something else for next/previous class...)

Any keyboard suggestions welcomed provided a consensus is reached... ;-)

 


Re: Start NCover Shortcut

Shortcuts changed in latest NCoverExplorer 1.3.5 beta

CTRL+N - Run NCover
ALT+LEFT/RIGHT - for Previous/Next unvisited line in class.
ALT+UP/DOWN - for Previous/Next unvisited class in namespace.

Download details are in this thread


Re: Why is it including My and My.Resource?

Farek,

If inside NCoverExplorer you look in the Options dialog you will see a coverage exclusions tab. By default NCoverExplorer used to (no longer in the very latest builds) add two coverage exclusions as starting point examples - one for assemblies ending in .Tests, and the other for Namespaces in the format .My

The second one of those is what is catching one of your scenarios and not the other. When the My classes are in the root namespace they dont get caught by the expression
.My - they would instead need My.

So fiddle with the exclusions to match what meets your requirements. Im a C# developer myself so it's all just noise to me I get to avoid... ;-)

If you are automating the coverage reporting using NAnt/MSBuild or just the ncoverexplorer.console.exe doing an exec then in all three situations you can specify exclusions via the parameters to those tasks etc.



Re: Why is it including My and My.Resource?

Thank you very much! Just what I was looking for :)

I just had to add a config file with the following :

<CoverageExclusion>
     <ExclusionType>Namespace</ExclusionType>
     <Pattern>My*</Pattern>
</CoverageExclusion>

Best Wishes,
Farek


Re: Why is it including My and My.Resource? - Command line pleas

What is the format for the command line if I wanted to exclude some assemblies?

For example, I would like to use a syntax something like this to exclude the assemblies "Microsoft.Practices.CompositeUI.DLL" and Infrastructre.DLL

"C:\Program Files\NCoverExplorer\NCoverExplorer.Console.exe" NCover1.xml  /x:NCoverExplorerReport.xml /p:NCoverExplorerProjectName /m:85 /f:71 /exclude:"Microsoft.*, Infrastructure.*"

so that I can specify a list of assemblies from within a command line in a VisualBuild script running on a build PC.

I can see how to do it from NCoverExplorer gui, and I can see what appears in the NCoverExplorer.config file after changing things (excluding) in the GUI but I would like to have more control to change things within different build scripts.

Nigel

 


Re: Why is it including My and My.Resource? - Command line pleas

Hi Nigel,

It is not possible to do exclusions directly in the command line due to the complexity of the parameters involved. Exclusions must indicate their type (assembly, class, method) as well as their value and nowadays whether they are a regular expression or not.

So your only options are to either use a .config file, or alternatively use the NAnt/MSBuild tasks which are designed to be a more reusable option.


Re: Why is it including My and My.Resource? - Command line pleas

I use Visual Studio 2005, but not MSBuild. Is there something simple I could do so that I create an MSBuild proejct which just runs NCoverExplorer and feeds in the options previously mentioned.

Nigel


Re: Why is it including My and My.Resource? - Command line pleas

Absolutely. If you look in the NCoverExplorer.Extras.zip you will see an example .proj file for msbuild showing the syntax required with various examples. You can also see the examples in the documentation for the tasks, such as at this link:

http://www.kiwidude.com/dotnet/doc/NCoverExplorer.MSBuildTasks/


Re: Why is it including My and My.Resource? - Command line pleas

Grant

I am still struggling. I have not used MSBuild so do not understand what the MSBuild examples are getting at.

We use Kinook's VisualBuild for building.

I have generate NCover output by running NUnit tests and fed this into NCoverExplorer console. I have customised the .config file to exclude assemblies such as Microsoft.*. The NCoverExplorer console output (see below) indicates that files are being excluded, yet the report file still have these files included. This gives me a problem as the total coverage figure is very low...

Any suggestions?

NCoverExplorer.Console 1.3.5.1921

(c) 2006 Grant Drake

http://www.ncoverexplorer.org/

-----------------------------------------

Using .config file: C:\TH\TalysurfCCI\Build\NCoverExplorerCci.config

-- Options:

Project Name: NCoverExplorerProjectName

Acceptance%: 85%

Sort: Name

Filter: None

Xml Report: C:\TH\TalysurfCCI\Build\NCoverExplorerReport.xml

Html Report: N/A

Report Type: ModuleSummary(1)

Merge To: N/A

Exclusions: (No report footer section)

- any Assembly matching *.Tests (IsRegex=False)

- any Assembly matching Microsoft.* (IsRegex=False)

- any Assembly matching ms*.* (IsRegex=False)

- any Assembly matching cciic.dll (IsRegex=False)

- any Assembly matching CCISystem.dll (IsRegex=False)

- any Assembly matching Infrastructure.* (IsRegex=False)

- any Namespace matching UnitTest*.* (IsRegex=False)

-- Loading file: C:\TH\TalysurfCCI\Source\CCISol\CCIApp\bin\Release\Coverage2.xml...

-- Calculating coverage and applying exclusions...

-- Sorting...

-- Coverage file parsing complete.

7.709662% coverage, 44998 unvisited sequence points in 1 coverage file(s).

-- Applying command line options ...

-- Generating summary report...

[OK] - Xml report created: C:\TH\TalysurfCCI\Build\NCoverExplorerReport.xml


Re: Why is it including My and My.Resource? - Command line pleas

Hi Nigel,

Would you like to zip and e-mail me the "coverage2.xml" file, your "NCoverExplorerCci.config" file, and the "NCoverExplorerReport.xml" output so I can take a look? My email address is support at ncoverexplorer dot org. I don't need any source code and any files you sent are deleted after resolving the issue so hopefully you shouldnt have any confidentiality concerns.


Re: Why is it including My and My.Resource? - Command line pleas

Grant

You should have the zip file by now.

Nigel


Re: Why is it including My and My.Resource? - Command line pleas

Hi Nigel,

No sign of it as yet - when did you send it? Its possible it got chewed up by a spam checker or something, would you like to forward it again? If you zip the files, you could try rar'ing them or even changing the extension to .archive to see if that gets through.


Re: Why is it including My and My.Resource? - Command line pleas

Hi Nigel,

Thanks for that - it did all come through.

The problem is mostly a simple misunderstanding on the assembly exclusion patterns - the "Assembly" name refers to how it is defined in the coverage.xml file with the "assembly" attribute, which is shown as the name of the assembly node in the tree in the NCoverExplorer gui. Basically it means it should have no .dll suffix.

It's the same deal as when you use the //a argument to call NCover specifying which assemblies to profile - you just specify the assembly names with no paths or .dll/.exe suffixies. If you are calling NCover from the command line you might like to change your script to to make use of that argument.

Anyways, please change your various exclusion patterns as follows:
- "ms." to "ms" (to exclude the assembly "msvcm80" which you thought of as "msvcm80.dll)
- "cciic.dll" to "ccicc"
- "ccisystem.dll" to "ccisystem"

The final one that failed was the namespace one of "UnitTest
.", which failed to exclude the "UnitTest.Library.xxx" class for instance. I got it to work by changing the pattern to "UnitTest.". Basically there is an "undocumented limitation" to my simplistic implementation which you just managed to hit - that is that you cannot have a * wildcard in the middle of your pattern. I will add it as a bug to look at in a future release.

That should be sufficient to get you up and running...


Re: Why is it including My and My.Resource? - Command line pleas

Grant

Apologies for my delayed reply.

Your suggestions worked fine. Thanks.

Nigel


Re: Why is it including My and My.Resource? - Command line pleas

FYI the restriction of wildcards only being supported at the beginning or end has been fixed for the upcoming NCoverExplorer 1.3.6 release - it will then be possible to do for instance MyApp.Test*.NUnit or whatever combination you require. There is also regular expression support in 1.3.5 so between that lot people should have as much flexibility as they need.