avr.
30
2008

Run NCover through MSBuild in Team City

After one comment of Chris Walquist on one of my last post about Team City integration of NCover here is the way I run NCover through MSBuild in Team City.

First I need to import the Task of NCover.

<ProjectToolsVersion="3.5"DefaultTargets="Build"xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <UsingTask
TaskName="NCoverExplorer.MSBuildTasks.NCover"AssemblyFile="$(NCoverPath)\Build Task Plugins\NCoverExplorer.MSBuildTasks.dll" />
  <UsingTask
TaskName="NCoverExplorer.MSBuildTasks.NCoverExplorer"AssemblyFile="$(NCoverPath)\Build Task Plugins\NCoverExplorer.MSBuildTasks.dll" />

Then I define some properties:

    <!-- NCover -->
    <SolutionFolder>$(MSBuildProjectDirectory)\..\..</SolutionFolder>
    <TestsFolder>$(MSBuildProjectDirectory)\..\..\Tests</TestsFolder>
    <NCoverPath>C:\Program Files\NCover</NCoverPath>
    <NUnitPath>C:\Program Files\NUnit 2.4.6\bin</NUnitPath>
    <TestDll>TechHeadBrothers.Portal.DataAccess.Tests.dll TechHeadBrothers.Portal.DataAccess.dll</TestDll>
    <CoverageFile>..\..\Tests\Output\Coverage.xml</CoverageFile>
    <CoverageExclusions>Assembly=*.Tests</CoverageExclusions>
    <CoverageAssemblies>TechHeadBrothers.Portal.DataAccess;TechHeadBrothers.Portal.Domain;</CoverageAssemblies>

Then I have two targets:

  <Target Name="FullCoverage">
    <Message Text="#--------- Executing NCover ---------#" />
    <NCover ToolPath="$(NCoverPath)" 
            CommandLineExe="$(NUnitPath)\nunit-console.exe" 
            CommandLineArgs="$(TestDll)" 
            WorkingDirectory="$(TestsFolder)\Output\bin\Debug" 
            ProjectName="$(ProjectName)" 
            CoverageFile="$(CoverageFile)" 
            FileExclusionPatterns="$(CoverageExclusions)" 
            LogFile="Coverage.log" 
            AssemblyList="$(CoverageAssemblies)" />
    <!-- Summary Page -->
    <NCoverExplorer ToolPath="$(NCoverPath)" 
                    ProjectName="$(ProjectName)" 
                    OutputDir="$(TestsFolder)\Output" 
                    CoverageFiles="$(CoverageFile)" 
                    SatisfactoryCoverage="80" 
                    ReportType="ModuleClassSummary" 
                    HtmlReportName="CoverageSummary.html" />
    <!-- Full HTML Report -->
    <NCoverExplorer ToolPath="$(NCoverPath)" 
                    ProjectName="$(ProjectName)" 
                    OutputDir="$(TestsFolder)\Output\Coverage" 
                    CoverageFiles="$(CoverageFile)" 
                    SatisfactoryCoverage="80" 
                    ReportType="FullCoverageReport" 
                    HtmlReportName="Coverage.html" />
  </Target>

And finally in the target AfterBuild (more on that in this post) I call target SummaryCoverage or FullCoverage according to the configuration:

  <Target Name="AfterBuild">
    <CallTarget Condition=" '$(Configuration)' == 'Staging' " Targets="SummaryCoverage" ContinueOnError="false" />
    <CallTarget Condition=" '$(Configuration)' == 'Nightly' " Targets="FullCoverage" ContinueOnError="false" />

That's it!

Then Chris asked the following:

1) How did you get your "tests" tab to show up as well?  Did you have to run the tests with NUnitLauncher, and then run again for coverage?  I read that NUnitLauncher can't be used to profile, since it kicks off a separate process.

2) How did you get the "classes", "header", "index", etc. files?  I just get the summary.html.  I see options for this in ncover.console.exe but not in the <NCoverExplorer> target.

3) Did you use wildcard expressions to pass a list of test assemblies to NCover?  If so, would like to see how you did that, too.

1) I get the test tab configuring Team City to run my unit tests. That has nothing to do with NCover. And yes doing it so seems to run two time all unit tests. Here is a screen shot of my team city runner configuration:

2) Read this post "Using NDepend in Team City build management tool" that talks about for NDepend but shows configuration for NCover too.

3) The answer is on top of this post!

Hope it helps!

Commentaires (4) -

http://

Very important to note to that if you are using NCover 3.0, there are several breaking changes listed here that you should check out...

www.ncover.com/.../breakingchanges

http://

Have you updated to NCover 3 and TeamCity 4.0.2?

If so can you provide updated documentation to the above references? I'm trying to follow through and convert your install to mine.

Any feedback would be greatly appreciated.

Thanks
Callon

lkempe

Callon: Yeah I updated to NCover 3 and TC 4.0.2. I will do another blog post to show the slight differences!

http://

In response to simone_b, NCover 1.5.8 will run on a 64bit OS. See abdullin.com/.../...cover-on-a-64-bit-machine.html

Ajouter un commentaire

  Country flag

biuquote
  • Commentaire
  • Prévisualiser
Loading

About Laurent

Laurent Kempé

Laurent Kempé is the editor, founder, and primary contributor of Tech Head Brothers, a French portal about Microsoft .NET technologies.

He is currently employed by Innoveo Solutions since 10/2007 as a Senior Solution Architect, certified Scrum Master and Founding Member.

Founder, owner and Managing Partner of Jobping, which provides a unique and efficient platform for connecting Microsoft skilled job seekers with employers using Microsoft technologies.

Laurent was awarded Most Valuable Professional (MVP) by Microsoft from April 2002 to April 2012.

JetBrains Academy Member
Certified ScrumMaster
My status

Twitter

Flickr

www.flickr.com
This is a Flickr badge showing public photos and videos from Laurent Kempé. Make your own badge here.

Month List

Page List

Laurent Kempé | Conversion from Visual Studio .Net 2003 to Visual Studio 2005
Mar
3
2005

Conversion from Visual Studio .Net 2003 to Visual Studio 2005

This evening (hum morning ;) I decided to give a try to the conversion wizard integrated in Visual Studio 2005 that let you import older 1.1 projects.
I choosed to import my whole website: Tech Head Brothers. You might see next the conversion report:

And the Error List report of a build :

I am impressed about the conversion. Ok I have 2 errors and 133 Warnings, but the warnings are all due to deprecated classes or obsolete methods and the two errors are:

  • Error 134 Program '\Projects\Tech Head Brothers Portal\Database\obj\Debug\Database.exe' does not contain a static 'Main' method suitable for an entry point Database
  • Error 135 Program '\Projects\Tech Head Brothers Portal\Docs\obj\Debug\Docs.exe' does not contain a static 'Main' method suitable for an entry point Docs

Next step is to get the DB in SQL Server 2005 and make some tests. But that the task for another day.

Tomorrow I will be at the French DevDays 2005 in Strasbourg, hope to meet you there.

Add comment

  Country flag

biuquote
  • Comment
  • Preview
Loading

About Laurent

Laurent Kempé

Laurent Kempé is the editor, founder, and primary contributor of Tech Head Brothers, a French portal about Microsoft .NET technologies.

He is currently employed by Innoveo Solutions since 10/2007 as a Senior Solution Architect, certified Scrum Master and Founding Member.

Founder, owner and Managing Partner of Jobping, which provides a unique and efficient platform for connecting Microsoft skilled job seekers with employers using Microsoft technologies.

Laurent was awarded Most Valuable Professional (MVP) by Microsoft from April 2002 to April 2012.

JetBrains Academy Member
Certified ScrumMaster
My status

Twitter

Flickr

www.flickr.com
This is a Flickr badge showing public photos and videos from Laurent Kempé. Make your own badge here.

Month List

Page List