将 Hudson 与 MS Test 集成?
是否可以将 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文件是否可以转换为JUnit 或 NUnit 结果格式(因为 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
我一直想写这篇文章作为指南并开发一个插件,但我还没有抽出时间。 我知道这个问题已经很老了,但我确信其他人也想要同样的东西,所以就在这里。
在 Hudson 上的项目配置中:
执行 Windows 批处理命令
然后选中“发布 NUnit 测试结果报告”框,并为“测试报告 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
Then check the box "Publish NUnit test result report" and for "Test report XMLs" enter
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.
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.
我已经能够使用“hangy's”命令行的变体和 MSTest 插件来成功运行和分析/发布测试用例。 我所做的最大更改是指定 mstest.exe 的输出文件,并让 MSTest 插件使用该文件(不允许使用通配符...必须是实际文件名)。 例如,以下是我的自定义构建步骤:
exit 0
请注意,“结果文件”是相对于作业的工作区的。 因此,要解析的 MSTest 插件的结果文件是:
就是这样!
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:
exit 0
Notice that the "results file" is relative to the Job's workspace. Thus, the MSTest plugin's result file to parse is:
And that's it!
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.
我无法使用 Hudson 对 MS Test 结果进行历史分析,但我至少能够弄清楚,如果您使用 MSBuild 和 Exec 任务,Hudson 构建将正确标记为“失败”如果任何测试失败。
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.