Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/313.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何设置TeamCity/NAnt/Gallio/PartCover以显示测试结果?_C#_Continuous Integration_Nant_Teamcity_Gallio - Fatal编程技术网

C# 如何设置TeamCity/NAnt/Gallio/PartCover以显示测试结果?

C# 如何设置TeamCity/NAnt/Gallio/PartCover以显示测试结果?,c#,continuous-integration,nant,teamcity,gallio,C#,Continuous Integration,Nant,Teamcity,Gallio,这是我第一次建立teamcity,我在显示结果时遇到了一些问题。我想要一个运行NAnt脚本的构建步骤。脚本应该通过PartCover运行我的单元测试并显示结果。结果应该是: 通过的测试/失败的测试 覆盖率报告 但我真的不知道如何设置脚本或设置,甚至不知道应该在哪里查看这些结果(我猜是工件部分?)。使用下面的脚本,一切正常,但我无法查看任何报告 <project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

这是我第一次建立teamcity,我在显示结果时遇到了一些问题。我想要一个运行NAnt脚本的构建步骤。脚本应该通过PartCover运行我的单元测试并显示结果。结果应该是:

  • 通过的测试/失败的测试
  • 覆盖率报告
但我真的不知道如何设置脚本或设置,甚至不知道应该在哪里查看这些结果(我猜是工件部分?)。使用下面的脚本,一切正常,但我无法查看任何报告

<project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> 

<loadtasks assembly="C:\Program Files\Gallio\bin\Gallio.NAntTasks.dll" />

<target name="test"> 
  <gallio result-property="exitCode" failonerror="false" > 
    <runner-extension value="TeamCityExtension,Gallio.TeamCityIntegration" /> 
    <files> 
      <include name="%system.teamcity.build.checkoutDir%\Trunk\MyLibrary.Testing\bin\Release\MyLibrary.Testing.dll"/> 
    </files> 
  </gallio> 
  <fail if="${exitCode != '0'}" >One or more tests failed. Please check the log for more details</fail>    
</target>

</project>

一个或多个测试失败。请查看日志以了解更多详细信息
对于.Net Coverage部分,我选择了PartCover(2.2或2.3),但PartCover参数中没有任何内容(我应该吗?)


谢谢你的帮助

根据我的经验,你不应该直接管理Gallio。相反,您应该运行PartCover并在其命令行参数中指定Gallio作为目标。 您可以在此处找到有关Nant+PartCover的一些建议:

我遇到了NAnt的问题,决定只使用MSBuild。MSBuild更易于使用,并提供了非常描述性的错误消息。(我还发现我们的NCover许可证也如此使用)。这是我的剧本给任何感兴趣的人。我在网上的不同地方找到了它的代码

<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

  <PropertyGroup>
    <CoverageDir>.\Tests\Output\Coverage</CoverageDir>
    <CoverageFilesDir>.\Tests\Output\Coverage\files</CoverageFilesDir>
    <BinDir>Testing\bin\x86\Release</BinDir>
    <NCoverDir>C:\Program Files (x86)\NCover</NCoverDir>
    <GallioDir>C:\Program Files (x86)\Gallio\bin</GallioDir>
  </PropertyGroup>

  <UsingTask TaskName="NCover" AssemblyFile="$(NCoverDir)\Build Task Plugins\NCover.MSBuildTasks.dll" /> 
  <UsingTask TaskName="NCoverExplorer" AssemblyFile="$(NCoverDir)\Build Task Plugins\NCoverExplorer.MSBuildTasks.dll"/>

  <!-- Specify the tests assemblies --> 
  <ItemGroup> 
    <TestAssemblies Include="$(BinDir)\library.Testing.dll" />
    <CoverageAssemblies Include="$(BinDir)\library.dll" />
  </ItemGroup>

    <Target Name="Coverage">
      <Message Text="Creating $(CoverageFilesDir)" />
      <MakeDir Directories="$(CoverageFilesDir)"/>

      <Message Text="##-------------------- Running Coverage Reports --------------------##" /> 
      <Message Text="Coverage Assemblies @(TestAssemblies)" />

      <!--Run NCover to gather coverage information-->
      <NCover
      ToolPath="$(NCoverDir)"
      TestRunnerExe="$(GallioDir)\Gallio.Echo.exe"
      TestRunnerArgs="%(TestAssemblies.FullPath)"
      IncludeAssemblies="@(CoverageAssemblies)"
      LogFile="$(CoverageFilesDir)\%(TestAssemblies.Filename)-ncover.log"
      RegisterProfiler="false"
      CoverageFile="$(CoverageFilesDir)\%(TestAssemblies.Filename)-coverage.xml"/>    

      <CreateItem Include="$(CoverageFilesDir)\*-coverage.xml">
        <Output TaskParameter="Include" ItemName="CoverageReports"/>
      </CreateItem>

      <!--Generate coverage report-->
      <NCoverExplorer
        ToolPath="$(NCoverDir)"
        ProjectName="Library Coverage"
        ReportType="4"
        Sort="CoveragePercentageAscending"
        Filter="None"
        OutputDir="$(CoverageDir)"
        XmlReportName="CoverageReport.xml"
        HtmlReportName="CoverageReport.html"
        ShowExcluded="True"
        SatisfactoryCoverage="15"
        FailMinimum="False"
        CoverageFiles="@(CoverageReports)"/>

      <!-- In case one of the tests fails, make sure to stop TypeMock and unregister NCover. -->
      <OnError ExecuteTargets="test-finally"/>
  </Target>

  <!-- Stopping unregistering NCover is a separate target because it has to happen -->
  <!-- regardless of success or failure of the unit tests. Like the "finally" in a "try/finally" block. -->
  <Target Name="test-finally">
    <Exec Command="regsvr32 /u /s &quot;$(NCoverDir)\CoverLib.dll&quot;" ContinueOnError="true"/>
  </Target>

</Project>

.\Tests\Output\Coverage
.\Tests\Output\Coverage\files
测试\bin\x86\Release
C:\Program Files(x86)\n覆盖
C:\ProgramFiles(x86)\Gallio\bin