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 -->

23 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.

  7. Please let me know if you’re looking for a writer for your site.
    You have some really good posts and I feel I would
    be a good asset. If you ever want to take some of the load off, I’d absolutely love
    to write some articles for your blog in exchange for a link back to mine.
    Please shoot me an e-mail if interested. Regards!

    my site: sparrow pocket plus

  8. Appreciate this post. Will try it out.

  9. This post offers clear idea for the new viewers of blogging, that in fact
    how to do running a blog.

  10. Appreciating the hard work you put into your website and detailed information you offer.

    It’s good to come across a blog every once in a while that isn’t the same outdated rehashed material.
    Wonderful read! I’ve bookmarked your site and I’m
    including your RSS feeds to my Google account.

  11. Your thing is very unique compared to other folks I’ve read stuff from.
    I appreciate you for posting once you have an opportunity, Guess I’ll
    just bookmark this site.

    Also visit my web site; mini notebook wallet

  12. OwenTYokum says:

    Awesome blog you have here but I was wondering if you knew of any forums that cover the same topics
    discussed here? I’d really like to be a part of group where I
    can get advice from other experienced people that share the same interest.
    If you have any suggestions, please let me know.
    Kudos!

    Feel free to visit my web blog; OwenTYokum

  13. LarryTBowlen says:

    It’s an amazing article for all of the web
    visitors; they may get benefit from this I am certain.

    Also visit my webpage LarryTBowlen

  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.

3 × two =