The /publish
command is used to associate test runs/results with builds. MTM is displaying test results that are associated with test plans/suites which are somewhat independent of builds.
/publish: [ server name]
Use the /publish option to publish test data to the database for the
team project collection associated with the project's Team Foundation
Server. When you use the /publish option, you must correctly specify
the name of the Team Foundation Server. The correct format depends on
whether the Team Foundation Server has been registered on the client
computer, as described here: Command-Line options for publishing test
results
Using this command the results will successfully published to build.The published result is viewed in your build summary, but they don't appear in MTM. There is no way to view the result in MTM. Please refer this similar question.
TCM is a command line interface to running tests, similar to mstest, but it runs the tests through the infrastructure you set up in MTM. To publish .trx files to MTM/TFS, you're going to have to use tcm.exe
not mstest.exe
to get what you're after. Sample command as below:
tcm run /publish /suiteid:XXXX /configid:X /resultowner:"ABC XYZ" /resultsfile:C:\TempResult.trx /collection:http://<<TFS URL>> /teamproject:"My Project" /runowner:"ABC XYZ" /build:<<Build Number>> /builddefinition:<<Build Definition Name>>
Note: please double check your server url is suitable.