views:

992

answers:

5

Hello,

I'm trying to integrate PartCover.NET with NAnt and CruiseControl.NET I can run PartCover.NET browser without problems, but it does not work once I try to run it in an NAnt task (in my CCNET build).

There must be an issue with my NAnt target but I can't find it. Maybe someone had experienced the same issues in the past?.

    <target name="CoverageUnitTest" description="Code coverage of unit tests">
 <exec program="${PartCover.exe}">
  <arg value="--target=${NUnit.console}" />
  <arg value="--target-work-dir=${project.dir}\bin\${configuration}"/>
  <arg value="--target-args=${project}.dll" />
  <arg value="--output=C:\partcover.xml" />
  <arg value="--include=[*]*" />
 </exec>
</target>

In CruiseControl, I got the following error message: [exec] Invalid option '--target C:\NUnit\bin\nunit-console.exe'

Build Error: NAnt.Core.BuildException
External Program Failed: C:\PartCover\PartCover.exe (return code was -1)
in C:\default.build line: 20 col: 4

   at NAnt.Core.Tasks.ExternalProgramBase.ExecuteTask()
   at NAnt.Core.Tasks.ExecTask.ExecuteTask()
   at NAnt.Core.Task.Execute()
   at NAnt.Core.Target.Execute()
   at NAnt.Core.Project.Execute(String targetName, Boolean forceDependencies)
   at NAnt.Core.Project.Execute()
   at NAnt.Core.Project.Run()

thanks ! David

A: 

I managed to run the nant task using the line attribute of arg tag. But now I'm facing issues to integrate it in CruiseControl.NET. Thanks to provide details in this subject. David

davandries
+4  A: 

As You may have noticed this task is rather complicated. It drove me to the edge of insanity but at last I got it running.

Here is some general advice:

  • use PartCover version 2.2 instead of 2.3 since the latter is a dev version that seems to be unstable.

  • remember to register PartCover.CorDriver.dll.

  • passing arguments is the hardest part if You need to quote paths. I finally decided to use a configuration file and pass it via --settings.

The Chairman
using "<arg line=" instead of "<arg value=" works also
davandries
(+1) Register is a fundamental point, the error don't give no one clue about.
Luís Custódio
+1  A: 

I found the answers on how to integrate it thanks to the following blog post. http://blog.dynamicprogrammer.com/CategoryView,category,ContinuousIntegration.aspx

davandries
A: 

I am getting below error even after done everything as told above

partcover:

 [exec] Invalid option '--target=C:\Program Files\NUnit 2.5\bin\net-2.0\nunit-console.exe'
 [exec] ....\trunk\Source\test.build(99,4):
 [exec] External Program Failed: c:\Program Files\PartCover .NET 2.3\PartCover.exe (return code was -1)
rakesh motghare
A: 

Replace = with space and use the &quot ; marker around the parameters for the arguments