PageRenderTime 34ms CodeModel.GetById 18ms app.highlight 11ms RepoModel.GetById 1ms app.codeStats 1ms

HTML | 212 lines | 210 code | 1 blank | 1 comment | 0 complexity | 7ac6c97ee65fe8b13e963c8511579fa5 MD5 | raw file
  1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
  3    <head>
  4        <!-- $Id: NCoverFAQ.html 91 2006-01-17 23:51:02Z NCover $ -->
  5        <title></title>
  6        <meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR">
  7        <meta content="" name="vs_targetSchema">
  8        <style> body { font-size: 10pt; font-family: Verdana; }
  9	p.title { font-size: 20pt; font-weight: bold; }
 10	.subtitle { color: maroon; }
 11	p.question { font-weight: bold; }
 12	pre { font-size: 10pt; font-family: Courier; }
 13	pre.usage { background-color: #F0F0F0; }
 14	.quote { background-color: #F0F0F0; margin-left: 36pt;}
 15	.method { color: maroon; font-size: 10pt; font-weight: bold; }
 16	.hdrcell { background-color: #DDEEFF; font-size: 10pt; }
 17	.datacell { background-color: #FFFFEE; text-align: right; font-size: 10pt; }
 18	.hldatacell { background-color: #FFCCCC; text-align: right; font-size: 10pt; }
 19	.box { border: 1px solid; padding: 10px; }
 20        </style>
 21    </head>
 22    <body>
 23        <P class="title">NCover FAQ</P>
 24        <P>If you have questions that this document does not address, contact <A href="">
 25                Peter Waldschmidt</A>.</P>
 26        <P class="question">1. What is code coverage analysis?</P>
 27        <P class="answer">A code coverage analyzer monitors your code at runtime and 
 28            records information about which lines of code were executed. NCover shows each 
 29            sequence point in your application along with the number of times that point 
 30            was executed. Sequence points are generated by the compiler and stored in the 
 31            debug information (.pdb) files. A sequence point basically corresponds to a 
 32            single program statement (often a line of code) in your high-level language.</P>
 33        <P class="question">2. Why would I want to do code coverage analysis?</P>
 34        <P class="answer">Unit test suites are often used as a quality tool during the 
 35            development process to keep the codebase stable as it changes and expands. 
 36            Tools such as <A href="">NUnit</A> are often used to run and 
 37            report on the test suites. However, when implementing unit testing in your 
 38            build process, you have no way of knowing how much of your code the unit tests 
 39            are actually testing. This is where code coverage comes in. You can run NUnit 
 40            within NCover and use the code coverage report to determine which code was not 
 41            tested by that particular test suite.</P>
 42        <P class="question">3. What versions of the CLR does NCover support?</P>
 43        <P class="answer">At this time, NCover has only been tested on the .NET framework 
 44            version 1.1.4322.</P>
 45        <P class="question">4. What is the command line syntax for NCover?</P>
 46        <P class="answer">Here is the usage info from the NCover command line:</P>
 47        <pre class="usage">Usage: NCover /c &lt;command line&gt; [/a &lt;assembly list&gt;]
 49/c Command line to launch profiled application.
 50/a List of assemblies to profile. i.e. "MyAssembly1;MyAssembly2"
 51/v Enable verbose logging (show instrumented code)
 52        </pre>
 53        <UL>
 54            <LI>
 55            The /c command-line argument is required and specifies the command-line of the 
 56            .NET application you want to analyze.
 57            <li>
 58            The /a command-line argument specifies the assemblies that you want to analyze. 
 59            NCover can only analyze assemblies that have .pdb files included with them. If 
 60            you do not specify the /a argument, NCover will attempt to analyze every loaded 
 61            assembly that has debug information available.
 62            <li>
 63                The /v command-line argument makes the profiler emit all the original IL and 
 64                modified IL instructions to the coverage log. This is useful for debugging 
 65                purposes. Beware that this can make your coverage log file very large!
 66            </li>
 67        </UL>
 68        <P class="question">5. Does NCover required a special compilation step for my code?</P>
 69        <P class="answer">No. Some code coverage tools change your source code and force 
 70            you to recompile it into a special build.&nbsp; NCover is designed to&nbsp;work 
 71            on shipping code.&nbsp; NCover uses the .NET Framework profiling API to monitor 
 72            your code. It does require build symbols, but can be run on release code 
 73            without any modifications.</P>
 74        <P class="question">6. How does NCover work?</P>
 75        <P class="answer">NCover uses the .NET Framework profiler API to monitor an 
 76            application's execution. When a method is loaded by the CLR, NCover retrieves 
 77            the IL and replaces it with instrumented IL code.&nbsp; NCover does not change 
 78            your original IL code, it simply inserts new code to update&nbsp;a visit 
 79            counter at each sequence point.&nbsp; After&nbsp;the .NET&nbsp;process 
 80            shuts&nbsp;down, the profiler outputs statistics to a file in the current 
 81            directory.
 82        </P>
 83        <P class="question">7. How do I analyze an ASP.NET application with NCover?</P>
 84        <P class="answer"><STRONG>xmspc</STRONG> got this to work on ASP.NET. See his post 
 85            on the message board for more information. Here are the basics for getting it 
 86            to work on Windows XP.
 87        </P>
 88        <div class="quote">
 89            <P class="answer">
 90                1) Ensure the NCoverLib COM component is registered (setup does this, but you 
 91                can manually register it with regsvr32 if you wish).
 92            </P>
 93            <P class="answer">
 94                2) Set the machine-wide COR profiling environment variables (or find some other 
 95                way to get them set in the aspnet_wp.exe's environment):
 96                <BR>
 97                &nbsp;&nbsp;COR_ENABLE_PROFILING=1
 98                <BR>
 99                &nbsp;&nbsp;COR_PROFILER=CvrLib.CoverageProfiler
100            </P>
101            <P class="answer">3) Create %windir%\System32\Coverage.log and 
102                %windir%\System32\Coverage.xml and grant .\ASPNET read+write+modify permission 
103                to these 2 files only.
104            </P>
105            <P class="answer">4) Force a restart of IIS so aspnet_wp.exe picks up the new 
106                environment variables.&nbsp;Coverage info will be written to the System32 
107                directory.
108            </P>
109            <P class="answer">All ASP.Net processes (on Windows XP for sure, don't know about 
110                Windows 2003) use %windir%\System32 as their working dir, therefore if multiple 
111                processes are running they will stomp over the Coverage files.
112            </P>
113            <P class="answer">...would be nice if NCover used AppDomain basedir and/or value 
114                from app config file to set output file dir...
115            </P>
116        </div>
117        <P class="question">8. What is the output of NCover?</P>
118        <P class="answer">NCover writes three files to the directory after analysis 
119            completes.
120            <ul>
121                <li>
122                Coverage.log - This file is a log of the events and messages from the profiler 
123                during the analysis process. Most of the time, error messages are recorded in 
124                this log. If you enable verbose logging, the coverage log will contain 
125                disassembly of the original and instrumented IL code.
126                <li>
127                Coverage.xml - This file is the analysis output of NCover. You can see an 
128                example of the output below.
129                <LI>
130                    Coverage.xsl - This file is a simple XML transformation that makes the XML 
131                    output easily readable.
132                </LI>
133            </ul>
134            <span class="subtitle">Example XML output</span>
135            <div class="box"><pre>&lt;method class="NCoverTest.ClassLoaded" name="HasDeadCode"&gt;
136    &lt;seqpnt document="C:\Dev\Utilities\ncover\NCoverTest\NCoverTest.cs"
137            column="13" line="48" endcolumn="58" endline="48" visitcount="1" /&gt; 
138    &lt;seqpnt document="C:\Dev\Utilities\ncover\NCoverTest\NCoverTest.cs" 
139            column="13" line="49" endcolumn="22" endline="49" visitcount="1" /&gt; 
140    &lt;seqpnt document="C:\Dev\Utilities\ncover\NCoverTest\NCoverTest.cs" 
141            column="17" line="50" endcolumn="24" endline="50" visitcount="1" /&gt; 
142    &lt;seqpnt document="C:\Dev\Utilities\ncover\NCoverTest\NCoverTest.cs" 
143            column="13" line="51" endcolumn="48" endline="51" visitcount="0" /&gt; 
144    &lt;seqpnt document="C:\Dev\Utilities\ncover\NCoverTest\NCoverTest.cs" 
145            column="9" line="52"  endcolumn="10" endline="52" visitcount="0" /&gt; 
147            </div>
148        <p></p>
149        <span class="subtitle">Example transformed output</span>
150        <div class="box">
151            <DIV class="method">NCoverTest.ClassLoaded.HasDeadCode</DIV>
152            <TABLE id="Table1" borderColor="black" cellSpacing="0" cellPadding="3" border="1">
153                <TBODY>
154                    <TR>
155                        <TD class="hdrcell">Visit Count</TD>
156                        <TD class="hdrcell">Line</TD>
157                        <TD class="hdrcell">Column</TD>
158                        <TD class="hdrcell">End Line</TD>
159                        <TD class="hdrcell">End Column</TD>
160                        <TD class="hdrcell">Document</TD>
161                    </TR>
162                    <TR>
163                        <TD class="datacell">1</TD>
164                        <TD class="datacell">48</TD>
165                        <TD class="datacell">13</TD>
166                        <TD class="datacell">48</TD>
167                        <TD class="datacell">58</TD>
168                        <TD class="datacell">C:\Dev\Utilities\ncover\NCoverTest\NCoverTest.cs</TD>
169                    </TR>
170                    <TR>
171                        <TD class="datacell">1</TD>
172                        <TD class="datacell">49</TD>
173                        <TD class="datacell">13</TD>
174                        <TD class="datacell">49</TD>
175                        <TD class="datacell">22</TD>
176                        <TD class="datacell">C:\Dev\Utilities\ncover\NCoverTest\NCoverTest.cs</TD>
177                    </TR>
178                    <TR>
179                        <TD class="datacell">1</TD>
180                        <TD class="datacell">50</TD>
181                        <TD class="datacell">17</TD>
182                        <TD class="datacell">50</TD>
183                        <TD class="datacell">24</TD>
184                        <TD class="datacell">C:\Dev\Utilities\ncover\NCoverTest\NCoverTest.cs</TD>
185                    </TR>
186                    <TR>
187                        <TD class="hldatacell">0</TD>
188                        <TD class="datacell">51</TD>
189                        <TD class="datacell">13</TD>
190                        <TD class="datacell">51</TD>
191                        <TD class="datacell">48</TD>
192                        <TD class="datacell">C:\Dev\Utilities\ncover\NCoverTest\NCoverTest.cs</TD>
193                    </TR>
194                    <TR>
195                        <TD class="hldatacell">0</TD>
196                        <TD class="datacell">52</TD>
197                        <TD class="datacell">9</TD>
198                        <TD class="datacell">52</TD>
199                        <TD class="datacell">10</TD>
200                        <TD class="datacell">C:\Dev\Utilities\ncover\NCoverTest\NCoverTest.cs</TD>
201                    </TR>
202                </TBODY>
203            </TABLE>
204        </div>
205        <P></P>
206        <P class="question">9. How do you test NCover?</P>
207        <P class="answer">Unfortunately, all the original testing was done with production 
208            code that cannot be published. I have started on a test suite called 
209            NCoverTest. It is pretty anemic right now, but feel free to chip in and 
210            contribute some tests.</P>
211    </body>