如何从 PartCover 结果 .xml 生成 HTML 报告

发布于 2024-07-25 13:20:37 字数 39 浏览 5 评论 0原文

如何从 PartCover 结果 .xml 生成 HTML 报告

How to generate an HTML report from PartCover results .xml

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

长途伴 2024-08-01 13:20:38

您可以使用一个工具来生成 HTML 报告:

https://github.com/danielpalme/ReportGenerator

在这里您可以找到一篇如何将该工具集成到 MSBuild 中的文章:

http://www.palmmedia.de/Blog/2009/10/30/msbuild-code-coverage-analysis-with-partcover-and-reportgenerator

There is a tool you can use to generate a HTML report:

https://github.com/danielpalme/ReportGenerator

Here you can find an article how to integrate the tool into MSBuild:

http://www.palmmedia.de/Blog/2009/10/30/msbuild-code-coverage-analysis-with-partcover-and-reportgenerator

吃素的狼 2024-08-01 13:20:38

据我所知,没有像 NCoverExplorer 这样方便的工具可以将 PartCover 结果 .xml 文件转换为 .html 报告,但 CruiseControl.NET 中有一些 .xsl 文件可用于将 PartCover 结果转换为 .html: a href="http://confluence.public.thoughtworks.org/display/CCNET/Using+CruiseControl.NET+with+PartCover" rel="nofollow noreferrer">将 CruiseControl.NET 与 PartCover 结合使用。

您可以从 CruiseControl.NET 获取这些 .xsl 文件,并使用 Sandcastle 之类的内容转换 PartCover results.xml的 XslTransform.exe。

顺便说一句,如果这恰好与 TeamCity 有关,则即将发布的 5.0 版本将包括使用 PartCover 或 NCover 对 .NET 覆盖的支持。 有关详细信息,请参阅文档。 否则请忽略本段;-)

To my knowledge, there is no convenient tool like NCoverExplorer that can transform a PartCover results .xml file into a .html report, but there are some .xsl files that can be used to transform PartCover's results to .html in CruiseControl.NET: Using CruiseControl.NET with PartCover.

You could take those .xsl files from CruiseControl.NET and convert your PartCover results.xml using something like Sandcastle's XslTransform.exe.

By the way, if this happens to be related to TeamCity, the upcoming 5.0 release will include support for .NET coverage using PartCover or NCover. See the documentation for more informations. Otherwise ignore this paragraph ;-)

以为你会在 2024-08-01 13:20:38

最简单的解决方案可能是使用 msxsl,一个简单的命令行转换器。 我正是出于这个目的使用它,并且它很容易集成到您的构建系统中。

http://www.microsoft.com/downloads/details.aspx microsoft.com/downloads/details.aspx?FamilyID=2FB55371-C94E-4373-B0E9-DB4816552E41&displaylang=en

Easiest solution is probably to use msxsl, a simple command line transformer. I use it for exactly this purpose, and it's easy to integrate into your build system.

http://www.microsoft.com/downloads/details.aspx?FamilyID=2FB55371-C94E-4373-B0E9-DB4816552E41&displaylang=en

你在我安 2024-08-01 13:20:38

也许这是一种复杂的方法,但我是用 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=""$(MSBuildProjectDirectory)\..\Build\Packages\Simian\simian-2.2.24.exe" -formatter=xml:$(MSBuildProjectDirectory)\..\Build\Artifacts\simian.xml -language=cs -excludes=$(MSBuildProjectDirectory)\..\Product\Production\**\*.Designer.cs $(MSBuildProjectDirectory)\Production\**\*.cs" >
</Exec>

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

Maybe a complicated way of doing it, but I did this with the Simian xml report. Created an XSL file for the formatting, then wrote a dumb little console application;

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;
    }

Then I can call it from a MSBuild file like so;

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

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

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文