2009-07-02 50 views

回答

1

據我所知,一個HTML報告,有像NCoverExplorer沒有方便的工具,它可以改變一個PartCover結果.xml文件成.html報告,但有一些.xsl文件可用於將PartCover的結果轉換爲CruiseControl.NET中的.html:Using CruiseControl.NET with PartCover

您可以從CruiseControl.NET獲取這些.xsl文件,並使用類似Sandcastle的XslTransform.exe的方式轉換您的PartCover結果。順便說一下,如果這恰好與TeamCity相關,即將推出的5.0版本將包括使用PartCover或NCover支持.NET覆蓋。請參閱documentation瞭解更多信息。否則忽略這一段;-)

+0

哦,等等,我知道那個名字。你是TeamCity開發人員之一!在這種情況下,請忽略我最後一段。這是一個小世界畢竟:) – Cygon 2009-08-27 06:52:44

+0

LoL兄弟,最後一段很有趣:) – 2010-04-21 15:46:16

0

也許是一個複雜的做法,但我用Simian XML報告做到了這一點。爲格式創建了一個XSL文件,然後編寫了一個愚蠢的小控制檯應用程序;

private const string MissingExtension = "Please enter a valid {0} file, this is missing the extension."; 
    private const string InvalidExtension = "Please enter a valid {0} file, the file provided has an invalid extension."; 

    public static void Main(string[] args) 
    { 
     if (args.Length < 2) 
     { 
      System.Console.WriteLine("Please enter a xsl file and xml file full path."); 
      return; 
     } 

     var xslFile = args[0]; 
     var xmlFile = args[1]; 

     if (!CheckFileNameFormat(xslFile, false)) 
      return; 
     if (!CheckFileNameFormat(xmlFile, true)) 
      return; 

     var transform = new XslCompiledTransform(); 
     // Load the XSL stylesheet. 
     transform.Load(xslFile); 
     // Transform xml file into an html using the xsl file provided. 
     transform.Transform(xmlFile, xmlFile.Replace("xml", "html")); 
    } 

    private static bool CheckFileNameFormat(string fileName, bool isXmlFile) 
    { 
     var extension = isXmlFile ? "xml" : "xsl"; 

     // valida that the argument has a period 
     if (fileName.IndexOf(".") < 1) 
     { 
      System.Console.WriteLine(string.Format(MissingExtension, extension)); 
      return false; 
     } 

     var filePieces = fileName.Split('.'); 
     // split on the period and make sure the extension is valid 
     if (filePieces[filePieces.GetUpperBound(0)] != extension) 
     { 
      System.Console.WriteLine(string.Format(InvalidExtension, extension)); 
      return false; 
     } 

     return true; 
    } 

然後我可以從這樣的MSBuild文件中調用它;

<Target Name="RunSimian" DependsOnTargets="RebuildSolution"> 

<Exec IgnoreExitCode="true" Command="&quot;$(MSBuildProjectDirectory)\..\Build\Packages\Simian\simian-2.2.24.exe&quot; -formatter=xml:$(MSBuildProjectDirectory)\..\Build\Artifacts\simian.xml -language=cs -excludes=$(MSBuildProjectDirectory)\..\Product\Production\**\*.Designer.cs $(MSBuildProjectDirectory)\Production\**\*.cs" > 
</Exec> 

<Exec IgnoreExitCode="true" Command="&quot;$(MSBuildProjectDirectory)\..\Build\Packages\XmlToHtmlConverter.exe&quot; $(MSBuildProjectDirectory)\..\Build\Packages\Simian\simian.xsl $(MSBuildProjectDirectory)\..\Build\Artifacts\simian.xml"> 
</Exec>