index > Visual Studio Team System - Developers > Code Coverage Coloring issue

Code Coverage Coloring issue


Hi everyone:

I have the following lines of code in a project under test:

if (PropertyTree.Length > 1 && PropertyTree[1] != "P")
{
// Use the P as the start object
o = risk;
CurrentProperty = 1;
}

When I turn on Code Coverage Coloring in the IDE, both lines inside the if-statement are blue, indicating that they were tested.

However, the if statement itself is beige, indicating that only part of that line was tested. Considering that this is an AND operation, I don't see how the if statement could have evaluated to "true" without testing both conditions? (unless the compiler somehow optimized away the second part because it already knew that PropertyTree[1] was not equal to "P", but how then can I turn that behavior off for unit tests?)

Is that a bug in the coloring logic, or am I missing something?

SA.

Speedbird186

SA,

We've seen some issues like this before and the end result of our investigations is usually the same. The results is almost always that the compiler is optimizing the IL for statements in ways that the user does not expect. The code coverage tool works exclusivly with code block so it regards that if statement as two totally seperate blocks. And apparently in the generated IL the complier has found some way to short circuit. I don't know any specific way to change compiler behaviour, but what I would recommend taking a quick look at the generated IL for that function. That way you can take a look at the IL to see what part of your execution path is getting skipped and how you can cover it. If you want, you can post that IL back here and I can take a look at it.

Thanks,

Ian




Ian Huff [MSFT] Developer on the Visual Studio Team System Profiler
Ian Huff
reply 2

You can use google to search for other answers

 

More Articles

Disable VS2005-specific features
Strange results for Code Coverage for a class using generics
Team build - 'enlistment is empty'
Intellisence in Skin files
Test Project Settings
Performance Tool crashing when it interprets VSP
Performance wizard
Two questions about profiling ASP.NET Applications
Problem getting performance sessions from unit tests
VSEnterpriseHelper error
Welcome to Bokebb   New Update   Joins the collection  
 

New Articles

TestManagement.ExecutionException?
How do I launch a "batch process&qu…
Any document about extensibility of prof…
How to annotate a valid input range to s…
Error when loading Microsoft.VisualStudi…
VSP1014 Error during instrumentation
Problems with vsperfcmd
Performance Profiler - OutOfMemoryExcept…
Benefits of Team System Developer vs. VS…
PRF0003: Launch Error: Executable file n…
MSTest "Specified cast is not valid…
Error in profiler report generation
"source view" for performance …
(Work Item) FileBrowse dialog launched f…
Source control and SQL stored proc.s

Hot Articles

Unit Testing Bug with xml value in My.Se…
Test framework in VS 2K5
Tests and deployment files in uplevel di…
Suggestions for managing SQL Server 2000…
ProfileLevel.Process level not working i…
Manually modifying vsmdi files
Excluding Warnings in FxCOP
TreeView automated checking
VisualStudio does not see multiple test …
Web test comments
Package Load Failure - PerformancePackage
code is being ignored by the Code Analys…
Using Unit Tests to drive the Profiler
Test projects and private/protected memb…
Errors profiling unsafe code

Recommend Articles

Code analysis vs FxCop
Error writing to file: Microsoft.VisualS…
Code Profilter listing function names as…
Does PREfast work with MAKE?
Partially Touched Code Question
Team build - 'enlistment is empty'
Resources: Team Edition for Software Dev…
How to create floating / dockable windows
Is that a bug with VSTS Beta2-"Erro…
Hatteras and Currituck in beta 3?
C#
Code Coverage loses it's mind
Errors profiling unsafe code
xslt for VS test and coverage results
Code Coverage not working