Publishing test results through command line test runner in VSTS

北战南征 提交于 2019-12-18 08:57:34

问题


I'm trying to use vstest.console.exe with the TfsPublisher logger in VSTS (cloud).

There's a URL example shown in the article for TFS onsite, but I'm trying to work out what parameters to use for my VSTS build. The example is:

/logger:TfsPublisher;Collection=http://localhost:8080/tfs/DefaultCollection;TeamProject=MyProject;BuildName=DailyBuild_20121130.1

But I just get an error saying the build cannot be found in the project, e.g.

Error: Build "1234" cannot be found under team project "MyProject".

I believe the problem is the BuildName parameter. My project and build definition have no spaces in the names. I have tried various values, e.g.:

BuildName=%BUILD_BUILDID% (resolves to number, e.g. 1234)
BuildName=%BUILD_DEFINITIONNAME% (resolves to build definition name OK)
BuildName=%BUILD_BUILDURI% (resolves to url, e.g. vstfs:///Build/Build/1234)

The error message confirms that the environment variables seem to be resolving OK, but I can't determine what I should substitute for "DailyBuild_20121130.1" in my case.

Updated: My vstest.console.exe logger parameter currently looks like

/logger:TfsPublisher;Collection=%SYSTEM_TEAMFOUNDATIONCOLLECTIONURI%;TeamProject=%SYSTEM_TEAMPROJECT%;BuildName=%BUILD_BUILDNUMBER%

回答1:


I effectively got the result I wanted using the Trx logger and one of the "Publish Test Results" build steps:

vstest.console.exe ... /logger:Trx




回答2:


The build name is generated by "Build number format" under build definition "General" tab. You can get it from "BUILD_BUILDNUMBER" variable.



来源:https://stackoverflow.com/questions/37656341/publishing-test-results-through-command-line-test-runner-in-vsts

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!