PowerShell script to extract Passed & Failed Data from a .trx file

Here is the powershell code that would allow you to extract Passed and Failed Data from a .trx file

This would enable to extract the data in a AzureDevops Task

<!-- wp:code -->
<pre class="wp-block-code"><code>
foreach($line in Get-Content $(System.DefaultWorkingDirectory)\TestResults$(Build.BuildId).trx) {
  
  
if($line -match '<Counters total="(?<total>.+)" executed="(?<executed>.+)" passed="(?<passed>.+)" error="(?<error>.+)" failed="(?<failed>.+)" ' )
    {
       $total=$($Matches.total)
       $passed=$($Matches.passed)
       $total+"/"+$passed
        $result=$total+"/"+$passed
         $(result)
Write-Host "##vso[task.setvariable variable=result]$total"
    }

}
</code></pre>
<!-- /wp:code -->

16 Responses

  1. Spot on with this write-up, I really think this amazing site needs
    far more attention. I’ll probably be returning to read through more,
    thanks for the advice!

  2. I have been exploring for a little for any high-quality articles or weblog posts on this kind of space
    . Exploring in Yahoo I ultimately stumbled upon this site.
    Studying this info So i’m satisfied to express that I have an incredibly good uncanny feeling I came upon exactly what I needed.

    I most indubitably will make certain to don?t fail to
    remember this site and provides it a look regularly.

  3. Hi there, this weekend is pleasant in favor of me, because this point in time i
    am reading this fantastic informative article here at my residence.

  4. Appreciate the recommendation. Will try it out.

  5. MurrayIDegen says:

    Wonderful work! This is the kind of information that are designed to be shared across the net.
    Disgrace on Google for no more positioning this publish higher!

    Come on over and talk over with my web site . Thanks =)

    Feel free to visit my web-site MurrayIDegen

  6. May I simply say what a comfort to discover somebody that genuinely knows what they’re talking about on the net.
    You certainly understand how to bring a problem to
    light and make it important. More and more people have
    to check this out and understand this side of your story.
    I was surprised that you are not more popular because you certainly possess the gift.

  1. December 5, 2020

    … [Trackback]

    […] Info on that Topic: azuredevopsguide.com/powershell-script-to-extract-passed-failed-data-from-a-trx-file/ […]

  2. December 14, 2020

    … [Trackback]

    […] Info on that Topic: azuredevopsguide.com/powershell-script-to-extract-passed-failed-data-from-a-trx-file/ […]

  3. December 15, 2020

    … [Trackback]

    […] Read More on on that Topic: azuredevopsguide.com/powershell-script-to-extract-passed-failed-data-from-a-trx-file/ […]

  4. December 22, 2020

    … [Trackback]

    […] Find More on that Topic: azuredevopsguide.com/powershell-script-to-extract-passed-failed-data-from-a-trx-file/ […]

  5. December 30, 2020

    … [Trackback]

    […] Find More on on that Topic: azuredevopsguide.com/powershell-script-to-extract-passed-failed-data-from-a-trx-file/ […]

  6. January 3, 2021

    … [Trackback]

    […] Read More on that Topic: azuredevopsguide.com/powershell-script-to-extract-passed-failed-data-from-a-trx-file/ […]

  7. January 12, 2021

    … [Trackback]

    […] Find More to that Topic: azuredevopsguide.com/powershell-script-to-extract-passed-failed-data-from-a-trx-file/ […]

  8. January 13, 2021

    … [Trackback]

    […] Information to that Topic: azuredevopsguide.com/powershell-script-to-extract-passed-failed-data-from-a-trx-file/ […]

  9. January 20, 2021

    … [Trackback]

    […] Find More to that Topic: azuredevopsguide.com/powershell-script-to-extract-passed-failed-data-from-a-trx-file/ […]

  10. January 23, 2021

    … [Trackback]

    […] Here you will find 87062 additional Information on that Topic: azuredevopsguide.com/powershell-script-to-extract-passed-failed-data-from-a-trx-file/ […]

Leave a Reply

Your email address will not be published.

thirteen + 8 =