将 Hudson 与 MS Test 集成?

发布于 2024-07-09 16:26:22 字数 800 浏览 6 评论 0原文

是否可以将 Hudson 与 MS Test 集成?

我现在正在使用 Hudson 在我的开发计算机上设置一个较小的 CI 服务器,这样我就可以获得一些统计数据(即 FxCop 和编译器警告)。 当然,如果它可以运行我的单元测试并显示它们的输出,那就太好了。

到目前为止,我已向 Hudson 添加了以下批处理任务,这使得它可以正确运行测试。

"%PROGRAMFILES%\Microsoft Visual Studio 9.0\Common7\IDE\MSTest.exe" /runconfig:LocalTestRun.testrunconfig /testcontainer:Tests\bin\Debug\Tests.dll

不过,据我所知,Hudson 还不支持对 MS Test 结果进行分析。 有谁知道MSTest.exe生成的TRX文件是否可以转换为JUnitNUnit 结果格式(因为 Hudson 支持这些),或者是否有其他方式集成 MS使用 Hudson 进行单元测试?

Is it possible to integrate Hudson with MS Test?

I am setting up a smaller CI server on my development machine with Hudson right now, just so that I can have some statistics (ie. FxCop and compiler warnings). Of course, it would also be nice if it could just run my unit tests and present their output.

Up to now, I have added the following batch task to Hudson, which makes it run the tests properly.

"%PROGRAMFILES%\Microsoft Visual Studio 9.0\Common7\IDE\MSTest.exe" /runconfig:LocalTestRun.testrunconfig /testcontainer:Tests\bin\Debug\Tests.dll

However, as far as I know, Hudson does not support analysis of MS Test results, yet. Does anyone know whether the TRX files generated by MSTest.exe can be transformed to the JUnit or NUnit result format (because those are supported by Hudson), or whether there is any other way to integrate MS Test unit tests with Hudson?

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

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

发布评论

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

评论(5

梦幻之岛 2024-07-16 16:26:22

我一直想写这篇文章作为指南并开发一个插件,但我还没有抽出时间。 我知道这个问题已经很老了,但我确信其他人也想要同样的东西,所以就在这里。

在 Hudson 上的项目配置中:

执行 Windows 批处理命令


SET MSTest="C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\MSTest.exe"
SET XSLParser="C:\MsBuildNunit\msxsl.exe"

SET TestDLL=path-to-your-test-projects.dll
SET TestOutFILE=TestResults\some-unique-filename.trx
SET TransformedOutputFile=%TestOutFILE:.trx=%.xml
SET XSLFile=c:\MsBuildNunit\MSBuild-to-NUnit.xslt

MKDIR TestResults

%MSTest% "/testcontainer:%TestDLL%" /nologo /resultsfile:%TestOutFILE% 

%XSLParser% %TestOutFILE% %XSLFile% -o %TransformedOutputFile%

SET ERRORLEVEL=0

然后选中“发布 NUnit 测试结果报告”框,并为“测试报告 XML”输入

TestResults/*.xml

There is an XSLT in C:\MsBuildNunit and msxsl .exe 来自微软。

您可以从此处下载 MSBuild-to-NUnit.xslt< /strong> 并从 microsoft 此处 或者您也可以获取我的 MsBuildNunit 文件夹的压缩副本,其中包含 xslt 和 exe 此处

运行时,它会调用 MSTest.exe,后者运行测试并以 microsoft trx (xml) 格式输出格式。 然后,它使用 xslt 和 trx 调用 msxsl.exe,并将其转换为 nunits xml 格式。 在构建结束时,Hudson 会像任何其他 Nunit 测试结果一样选择它,您就可以开始了。

编辑添加:
我忘了提及,通过这个 xslt,我们可以获得完整的测试结果。 我们有多个测试项目和多个 dll,我们通过趋势图、按名称查看测试、查看测试状态的能力获得了很好的反馈,如果出现错误,我们会收到错误消息以及堆栈跟踪。 基本上,您可以通过 Nunit 获得几乎所有功能。

编辑(再次):我刚刚在转换中添加了测试持续时间,因此它现在会显示在 Hudson 中! 似乎非常适合我们的测试。

编辑:我尝试了新的 MSTest 插件,它目前不支持解析多个 TRX 文件,仅支持 1 个,因此,如果您像我们一样并且拥有多个必须通过 MSTest 运行的测试程序集,那么目前这是您唯一的解决方案。

I've been meaning to write this as a guide and develop a plugin but I havent gotten around to it. I know this question is old but I'm SURE someone else out there wants the same thing so here it is.

In the project configuration on Hudson:

Execute Windows batch command


SET MSTest="C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\MSTest.exe"
SET XSLParser="C:\MsBuildNunit\msxsl.exe"

SET TestDLL=path-to-your-test-projects.dll
SET TestOutFILE=TestResults\some-unique-filename.trx
SET TransformedOutputFile=%TestOutFILE:.trx=%.xml
SET XSLFile=c:\MsBuildNunit\MSBuild-to-NUnit.xslt

MKDIR TestResults

%MSTest% "/testcontainer:%TestDLL%" /nologo /resultsfile:%TestOutFILE% 

%XSLParser% %TestOutFILE% %XSLFile% -o %TransformedOutputFile%

SET ERRORLEVEL=0

Then check the box "Publish NUnit test result report" and for "Test report XMLs" enter

TestResults/*.xml

There is an XSLT in C:\MsBuildNunit as well as msxsl.exe which comes from Microsoft.

You can download the MSBuild-to-NUnit.xslt from here and get msxsl.exe from microsoft here or you can just get the zipped copy of my MsBuildNunit folder that contains the xslt and exe here

When run, it calls MSTest.exe which runs the tests and outputs the format in microsofts trx (xml) format. Then it calls msxsl.exe with the xslt and the trx and translates it to nunits xml format. At the end of the build, Hudson picks it up as any other Nunit test result and you are good to go.

Edited to add:
I forgot to mention, with this xslt we get full test results. We have multiple test projects and multiple dll's and we get great feedback with the ability to trend graph, view the tests by name, view the statuses of the tests, and if it errors we get the error message along with the stack trace. Basically almost everything that you would get with Nunit.

Edit (again): I just now added the test duration in the transform so it will show up in Hudson now! Seems to work great for our tests.

Edit: I tried the new MSTest plugin and it currently does not support parsing multiple TRX files, just 1, so currently this is your only solution if you are like us and have multiple test assemblies that you have to run through MSTest.

治碍 2024-07-16 16:26:22

Hudson 有一个新的 MSTest 插件。 只需指定 .trx 文件的位置,工作就会为您完成。 如果该插件使用艾伦的解决方案,我不会感到惊讶。

Hudson has a new plugin for MSTest. Just specify the location of the .trx file and the work is done for you. It wouldn't surprise me if the plugin used Allen's solution.

神经暖 2024-07-16 16:26:22

我已经能够使用“hangy's”命令行的变体和 MSTest 插件来成功运行和分析/发布测试用例。 我所做的最大更改是指定 mstest.exe 的输出文件,并让 MSTest 插件使用该文件(不允许使用通配符...必须是实际文件名)。 例如,以下是我的自定义构建步骤:

"%PROGRAMFILES%\Microsoft Visual Studio 9.0\Common7\IDE\MSTest.exe" /runconfig:LocalTestRun.testrunconfig /testcontainer:MyProject1.Test/bin/Debug/MyProject1.Test.dll  /testcontainer: MyProject2.Test/bin/Debug/MyProject2.Test.dll /resultsfile:TestResults\HudsonJobTestResults.trx

exit 0

请注意,“结果文件”是相对于作业的工作区的。 因此,要解析的 MSTest 插件的结果文件是:

TestResults\HudsonJobTestResults.trx

就是这样!

I've been able to use a variation of "hangy's" command line, and the MSTest plugin to successfully run and analyze/publish the test cases. The biggest change I made was to specify the output file for mstest.exe and fore the MSTest plugin to consume that file (no wildcards allowed... must be actual filename). For example, the following is my custom build step:

"%PROGRAMFILES%\Microsoft Visual Studio 9.0\Common7\IDE\MSTest.exe" /runconfig:LocalTestRun.testrunconfig /testcontainer:MyProject1.Test/bin/Debug/MyProject1.Test.dll  /testcontainer: MyProject2.Test/bin/Debug/MyProject2.Test.dll /resultsfile:TestResults\HudsonJobTestResults.trx

exit 0

Notice that the "results file" is relative to the Job's workspace. Thus, the MSTest plugin's result file to parse is:

TestResults\HudsonJobTestResults.trx

And that's it!

流绪微梦 2024-07-16 16:26:22

Hudson 有一个绘图插件,可用于绘制通用数据。 如果每个图表有多个数据点,这不是最容易配置和使用的插件,但如果您可以解析 MS Test 输出并为插件生成输入文件,您至少可以绘制失败、成功和失败的趋势总测试。

Hudson has a Plot Plugin which can be used to plot generic data. It's not the easiest plugin to configure and use if you have multiple data points per graph, but if you can parse your MS Test output and generate input files for the plugin, you can at the very least plot the trends of failed, successful, and total tests.

天气好吗我好吗 2024-07-16 16:26:22

我无法使用 Hudson 对 MS Test 结果进行历史分析,但我至少能够弄清楚,如果您使用 MSBuild 和 Exec 任务,Hudson 构建将正确标记为“失败”如果任何测试失败。

<Exec Command=""C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\IDE\mstest.exe" /testcontainer:"MyAssembly.dll"" />

I've not been able to use Hudson to perform analysis of MS Test results for historical purposes, but I've at least been able to figure out that if you use MSBuild and the Exec task, the Hudson build will properly be marked as "failed" if any of the tests fail.

<Exec Command=""C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\IDE\mstest.exe" /testcontainer:"MyAssembly.dll"" />
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文