If you use vstest.console.exe, you are user of unit testing in Visual Studio. If you use it with /logger:TfsPublisher – you qualify as advanced user of vstest.console.exe. /logger switch lets you publish the results to the tfs server against a build & test runs show up on the build page.
// publishes results to the build vstest.console.exe mytests.dll /logger:TfsPublisher;Collection=http://mytfsserver:8080/tfs/DefaultCollection/;BuildName=MyBuild_20151222.1;TeamProject=myproj
It can publish results to either XAML Builds or new builds (tfs 2015). To publish test results from within TFS build 2015 – build definition enables to add “Publish test results” task out of the box. It can be used to publish the TRX file produced by other tasks during the build. It is not recommended to use /logger:tfspublisher from within a build. While it can be made to work, it may have pitfalls.
- The build runs in the context of a service or user based on how the build agent is configured. vstest.console.exe may not have access to the tfs server.
- The build number in the TFS 2015 – is by default of YYYYMMDD.N format – in the new build definition. It must be prefixed e.g. MyBuild_YYYYMMDD.N when editing the build definition. Otherwise – two build definitions may have the same build number & confuse the publisher. publishing may fail with error (Build 20151222.1 cannot be found under team project myproj).