Andrew

Find below our CodeCoverage MSBuild Target that we currently use to
integrate with NCover and NCoverExplorer. As you can see we filter out
our presentation assemblies as we currently have no unit tests for
them to create a CodeCoverageAssemblies ItemGroup.  The TestAssemblies
ItemGroup contains the names of all our existing Unit Test
assemblies.  We then run our tests via the NCover MSBuild task to
create individual coverage results file.  We then merge all of these
individual coverage files using the NCoverExplorer MSBuild task into a
single coverage file that is then integrated into the CC.NET report.

Both the NCover and NCoverExplorer MSBuild tasks are part of the
NCoverExplorer.Extras released by Grant Drake.  I documented our
complete CI setup at
http://dotnet.org.za/cjlotz/archive/2007/04/04/part-1-continuous-integration-using-msbuild-cruisecontrol-net-fxcop-nunit-ncover-subversion.aspx.
At that point in time we were still using NUnit, but we have
subsequently moved over to MbUnit.  Hope this helps :-)

Carel

   <Target Name="CodeCoverage">

      <!-- Find all SanQuote.Presentation assemblies -->
      <RegexMatch Input="@(CodeAssemblies)" Expression=".[\.]
(SanQuote.Presentation).*[\.]dll$">
         <Output TaskParameter="Output"
ItemName="PresentationAssemblies"/>
      </RegexMatch>

      <!-- Filter out the SanQuote.Presentation assemblies from the
coverage analysis -->
      <CreateItem Include="@(CodeAssemblies)"
                  Exclude="@(PresentationAssemblies)">
         <Output TaskParameter="Include"
ItemName="CodeCoverageAssemblies"/>
      </CreateItem>

      <Message Text="$(NEW_LINE)Running CodeCoverage for:$(NEW_LINE)$
(TAB)@(CodeCoverageAssemblies->'%(FileName)', '$(NEW_LINE)$(TAB)')$
(NEW_LINE)"
               Importance="high"/>

      <!-- Remove the old coverage files for the projects being
analysed -->
      <Delete Files="@(TestAssemblies->'%(FullPath).$(NCoverFile)')"/>

      <NCover
          ToolPath="$(NCoverPath)"
          CommandLineExe="$(MbUnitCmd)"
          CommandLineArgs="$(DOUBLE_QUOTES)%(TestAssemblies.FullPath)$
(DOUBLE_QUOTES) /report-type:xml /report-name-format:%
(TestAssemblies.Filename)%(TestAssemblies.Extension).$(MbUnitFile) /
report-folder:$(DOUBLE_QUOTES)%(TestAssemblies.RootDir)%
(TestAssemblies.Directory)"
          CoverageFile="%(TestAssemblies.FullPath).$(NCoverFile)"
          LogLevel="Normal"
          LogFile="%(TestAssemblies.FullPath).$(NCoverLogFile)"
          WorkingDirectory="%(TestAssemblies.RootDir)%
(TestAssemblies.Directory)"
          ExcludeAttributes=""
          Assemblies="@(CodeCoverageAssemblies)"
          RegisterProfiler="true"
          ContinueOnError="true"/>

      <!-- Create Item collection of all the coverage results -->
      <CreateItem Include="%(TestAssemblies.FullPath).$(NCoverFile)">
         <Output TaskParameter="Include" ItemName="NCoverResults"/>
      </CreateItem>

      <Message Text="NCoverResults:$(NEW_LINE)$(TAB)@(NCoverResults->'%
(FileName).$(NCoverFile)', '$(NEW_LINE)$(TAB)')$(NEW_LINE)"
Importance="low"/>

      <!-- Merge all the coverage results into a single summary
Coverage file -->
      <NCoverExplorer ToolPath="$(NCoverExplorerPath)"
                      ProjectName="$(MSBuildProjectName)"
                      OutputDir="$(Temp)"
                      Exclusions=""
                      CoverageFiles="@(NCoverResults)"
                      SatisfactoryCoverage="75"
                      ReportType="ModuleClassSummary"
                      HtmlReportName="$(CodeMetricsFolder)\$
(NCoverHtmlReport)"
                      XmlReportName="$(CodeMetricsFolder)\$
(NCoverSummaryFile)"
                      FailMinimum="False"/>

   </Target>


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"MbUnit.User" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/MbUnitUser?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to