1

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 Arguments には何もありません (すべきですか?)

ご協力いただきありがとうございます!

4

2 に答える 2

0

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>
于 2011-01-05T02:17:07.780 に答える
0

私の経験では、Gallio を直接実行するべきではありません。代わりに、PartCover を実行し、そのコマンドライン パラメータで Gallio をターゲットとして指定する必要があります。ここで、Nant+PartCover に関するいくつかのアドバイスを見つけることができます: Integrating PartCover.NET with NAnt

于 2010-12-28T16:01:05.837 に答える