TFS 团队构建日志单元测试结果
我们正在使用 TFS 2010 Team Build,它会在构建过程中自动运行我们的单元测试。如果单击“查看日志”,我可以看到运行的测试列表和每个测试结果(成功/失败)。如果发生失败,我想查看测试结果输出(以便开发人员可以找出失败的原因是什么)。仅在本地运行单元测试是不够的,因为问题可能是环境问题(如果测试因某些数据、服务器或物理路径而失败)。
如何更改构建过程模板以在日志中包含单元测试的完整结果?
查看日志页面中的 MSTest 命令行:
e:\Program Files\Common7\IDE\MSTest.exe /nologo /usestderr /testSettings:"E:\Builds\1\1\Sources\Source\TestSettings.testsettings" /searchpathroot:"E:\Builds\1\1\Binaries" /resultsfileroot:"E:\Builds\1\1\TestResults" /testcontainer:"E:\Builds\1\1\Sources\Source\Testing\bin\Release\Testing.dll" /publish:"http://tfs:8080/tfs/Projects" /publishbuild:"vstfs:///Build/Build/196" /teamproject:"Project" /platform:"Any CPU" /flavor:"Release"
摘要屏幕截图
http://imageshack.us /photo/my-images/28/tfsbuild.gif/
以及构建定义配置
http://imageshack.us/photo/my-images/835/builddefinition.gif/
谢谢。
We're using TFS 2010 Team Build which automatically runs our unit tests during the build process. If I click on View Log, I can see the list of tests run and each test result (Success/Fail). In the event of Failure, I want to see the test result output (so the developer can figure out what the cause of the failure is). Just running the unit test locally isn't enough because the issue could be environmental (if the test is failing because of some data, server, or physical path).
How can I change my build process template to include the full results of the unit test in the log?
MSTest command line from View Log page:
e:\Program Files\Common7\IDE\MSTest.exe /nologo /usestderr /testSettings:"E:\Builds\1\1\Sources\Source\TestSettings.testsettings" /searchpathroot:"E:\Builds\1\1\Binaries" /resultsfileroot:"E:\Builds\1\1\TestResults" /testcontainer:"E:\Builds\1\1\Sources\Source\Testing\bin\Release\Testing.dll" /publish:"http://tfs:8080/tfs/Projects" /publishbuild:"vstfs:///Build/Build/196" /teamproject:"Project" /platform:"Any CPU" /flavor:"Release"
Screenshot of summary
http://imageshack.us/photo/my-images/28/tfsbuild.gif/
And of the Build Definition configuration
http://imageshack.us/photo/my-images/835/builddefinition.gif/
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您使用默认模板并使用 Microsoft 提供的单元测试框架运行测试,您应该能够在构建详细信息的“查看摘要”页面上看到指向已发布测试结果的链接。单击此链接时,将从数据库下载测试结果并将其放在 trx 文件中,该文件将显示在 Visual Studio 的测试窗口中。
更新:查看日志后解决了问题。构建模板被自定义为使用另一个工具而不是 MSBuild 进行构建,因此不会创建每个配置(平台/风格)的摘要节点。这就是构建详细信息视图缺少摘要(包括测试结果)的原因。
If you use the default template and run the test using the unit test framework provided by Microsoft, you should be able to see a link to the published test results on the View Summary page of the build details. When you click at this link, the test results will be downloaded from the database and put together in an trx file that will be displayed in your Test Window in Visual Studio.
UPDATE: The problem was figured out after looking at the logs. The build template was customized to use another tool to build instead of MSBuild, and the summary nodes for each configuration (platform/flavor) were not created as a result. That's why the build details view was missing the summary, including the test results.
要使其发挥作用,您需要了解一个微小的细节。如果您使用 Web 门户查看构建的测试结果,您需要确保“结果”列显示“全部”(而不仅仅是“失败”)。如果全部通过,如果结果设置为失败,则不会列出任何内容。
这是我正在谈论的内容的小图片:
请注意我如何将“结果”列设置为“全部”。
现在,如果我选择全部作为结果,我可以看到列出的所有测试。如果双击任何测试,TFS Web 应用程序将导航至运行摘要。
与自动化链接的任何测试都会在摘要中提供链接,并且将附加任何 TRX 文件。打开 TRX 文件将显示 TestContext.WriteLine 输出以及其他数据,例如持续时间。
There is one tiny, little detail that you need to know to get this to work. If you are using the web portal to view the test results for a build, You want to make sure that the Outcome column displays All (not just Failed). If all passed, nothing would be listed if the Outcome was set to Failed.
Here is a little picture of what I'm talking about:
Notice how I have set the Outcome column to All.
Now, if I select All as the Outcome, I can see all the tests listed. If you double-click any test the TFS web app will navigate you to the Run summary.
Any tests that are linked with automation will have a Link provided to the Summary and any TRX files will be attached. Opening the TRX file will show the TestContext.WriteLine output, plus other data, like Duration.