Crap4Net was aimed to be incorporated into a continuous build server and therefore it main usage is via a the command line.
Before a CRAP report can be generated we need to produce data for the Code Coverage and Cyclomatic Complexity.
The following is a step by step guide in order to use the Crap4Net tool for generating a CRAP report:
Step 1 - Producing a coverage Report
2 tools can be used for this:
PartCover or Visual studio MSTest.
if using PartCover best course of action is to use suplied GUI to manualy produce the intial report and then export the setting into a config file which can then be used via command line. the result should look something similar to:
"c:\Program Files (x86)\Gubka Bob\PartCover .NET 2.3\partcover" --settings ..\..\PartCover.config
for more info on part cover is http://partcover.blogspot.com/
Some notes to remember
If using PartCover on 64 bit machine make sure to use CorFlags to set it to run in 32bit mode
If Using MsTest as the test runner coverage results will not show unless the NoIsolation flag is used in the test configuration
It easier to use and Crap4Net will handle the binary report as long as the all the relevant data will be supplied which includes:
MSTest coverage does not come with the professional edition of visual studio and require as a more advanced license
- the binary result fies (which usually is found under the "in" subdirectory of the test run
- the instrumented dll
- the PDB file of the instrumented dll.
Step 2 - Producing a Cyclomatic Complexity Report
we use Reflector for this, but it needs to be setup to do so.
Make sure that there are proper permissions to write to the output file, otherwise Reflector will crash with a very vague error message
- download the Reflector
Code Metric add-in, and add it to the Reflector add-in list (this is done by running the reflector and using the view menu.
- the command line looks somthing like: Reflector.exe /Run:Reflector.CodeMetrics /Assembly:"DummyProject.dll" /OutputPath:"ReflectorReport.xml"
Step 3 - Producing the Crap Report
edit the supplied config file to indicate the coverage tool used (either "MSTest" or "PartCover"), the cyclomatic complexity tool used, the reports files and the desired output file
and just run the tool.