Reputation: 175
In order to distribute the tests into different machine (remote way), we have to use the .testsettings file. In such file, we already configure to enable to collect the test coverage data by:
<DataCollectors>
<DataCollector uri="datacollector://microsoft/CodeCoverage/1.0" assemblyQualifiedName="Microsoft.VisualStudio.TestTools.CodeCoverage.CoveragePlugIn, Microsoft.VisualStudio.QualityTools.Plugins.CodeCoverage, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" friendlyName="Code Coverage (Visual Studio 2010)">
<Configuration>
<CodeCoverage keyFile="xxx.snk" xmlns="">
<Regular>
<CodeCoverageItem binaryFile="xxx.dll" pdbFile="xxx.pdb" instrumentInPlace="true" />
But the problem is the test coverage data never published back to the TFS server. When diagnostics the build process, the test result already can be published according to the build log:
Results file: d:\Builds\xxxx.trx
Test Settings: xxx
Waiting to publish...
Publishing results of test run xxx.trx to https://tfs.xxx/tfs/xxx...
Publish completed successfully.
It seems the coverage data isn't inside the xxx.trx file, and the build is not smart enough to allocate them and publish them. so from the build summary we can see:
23 modules instrumented - 0% of all code blocks covered
Is there any way to manually publish such data or write back the test coverage result back to the TFS server via some TFS API or coded activity?
[UPDATE] When check the test result file, it seems the result itself already contain the knowledge about how to find the .coverage file:
<ResultSummary outcome="Completed">
<ResultFile path="VM-TEST01\data.coverage" />
<ResultFile path="VM-TEST02\data.coverage" />
But the problem is the MSTest never publish them onto the TFS server!
Upvotes: 1
Views: 1605
Reputation: 5010
You need to
1). open the build definition, go to Process -> 3.Test -> Automated Test -> set the Type of run settings option to be UserSpecified.
2). Select the .testsettings file in the build definition.
Then, after a new build is queued, the code coverage data displayed on the Build Summary page:
Upvotes: 0