question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

VSTest task saves test results to wrong TestResults directory

See original GitHub issue

Hi all,

I’ve noticed that since a couple of weeks, Unit Tests results and Code Coverage files are no longer picked up by the SonarQube Scanner when running a build on VSTS using Hosted Agents. When I looked in the log, I saw that SonarQube can’t find any results files:

2016-10-03T09:58:06.3589980Z SonarQube Scanner for MSBuild End Step 2.1 2016-10-03T09:58:06.3589980Z 09:58:03.798 Fetching code coverage report information from TFS... 2016-10-03T09:58:06.3589980Z 09:58:03.799 Attempting to locate a test results (.trx) file... 2016-10-03T09:58:06.3599982Z 09:58:03.799 No test results files found

I found out that SonarQube is looking in the $(Common.TestResultsDirectory) for files (e.g. c:\a\1\TestResults), while the results and coverage files are written to $(build.SourcesDirectory)\TestResults (e.g. c:\a\1\s\TestResults). I expected them to be written to the Common.TestResultsDirectory.

It seems like the change in the VSTest task responsible for this was introduced by this commit. Line 159, which reads Common.TestResultsDirectory was deleted and replaced by this line.

    $testResultsDirectory = Get-TaskVariable -Context $distributedTaskContext -Name "Common.TestResultsDirectory"

    if([string]::IsNullOrEmpty($testResultsDirectory))
    {
        $testResultsDirectory = $workingDirectory + [System.IO.Path]::DirectorySeparatorChar + "TestResults"
    }`

Could you please look into this? Thanks!

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
mack0196commented, Oct 12, 2016

Why doesn’t vstest create the test results in $(Common.TestResultsDirectory)? I don’t understand why the same breaking consideration wasn’t considered when changing the TestResults directory.

1reaction
bobylevmcommented, Jan 24, 2017

@allendm-msft $(Common.TestResultsDirectory) is published as output/common variable at visualstudio.com: https://www.visualstudio.com/en-us/docs/build/define/variables

Read more comments on GitHub >

github_iconTop Results From Across the Web

VSTest task saves test results to wrong TestResults directory
Hi all, I've noticed that since a couple of weeks, Unit Tests results and Code Coverage files are no longer picked up by...
Read more >
PublishTestResults@2 - Publish Test Results v2 task
Specifies the folder to search for the test result files. mergeTestResults - Merge test results boolean . Default value: false . When this ......
Read more >
I need to append the test results of different VSTest tasks in to ...
I need the test results from both the tasks in the same folder(TestResult), so that I can generate the code coverage report for...
Read more >
VSTest task Error occurred while publishing test results ...
Hi,. We get an error after a test run has completed and the results are being reported. Total tests: 127 Passed: 127 Total...
Read more >
Why is my VSTest Runner test results file not bein...
Parsing test results under D:\agent-home\xml-data\build-dir\TRDSVR-LIN2-JOB1... 12-Dec-2017 13:38:33, Failing task since test cases were ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found