Capture the Executing output

Welcome Forums Pester Capture the Executing output

This topic contains 2 replies, has 3 voices, and was last updated by

 
Moderator
7 months ago.

  • Author
    Posts
  • #112339

    Participant
    Topics: 35
    Replies: 44
    Points: 26
    Rank: Member

    Hi

    Is it possible to capture the output of the tests. – Like below?

    Executing script .\Pester_Validate_Environment.Pester.test.ps1
    
      Describing Environment Validation
    
        Context Testing Environment
          [+] Can generate a security token 440ms
          [+] Can login 357ms
          [+] Can resolve internal links 530ms
    Tests completed in 1.33s
    Tests Passed: 3, Failed: 0, Skipped: 0, Pending: 0, Inconclusive: 0
  • #112366

    Participant
    Topics: 0
    Replies: 2
    Points: 22
    Rank: Member

    Pester uses Write-Host for that output, which historically has meant the answer is "no."

    However, in PowerShell v5+, Write-Host now uses the new information output stream. You can use a redirection operator to accomplish what you're looking for:

    $results = Invoke-Pester 6>&1
    $results
    

    That method doesn't acknowledge the -NoNewLine parameter of Write-Host, but I think it's as close as you'll get with Write-Host.

  • #112451

    Moderator
    Topics: 8
    Replies: 728
    Points: 2,025
    Helping Hand
    Rank: Community Hero

    If you want to show output to console as well as to a variable, use -InformationVariable common parameter.

    I would suggest you to use the built in output capabilities of pester. Pester can give detailed results in NunitXMl format and the can be used by different nunit readers to build beautiful html reports.

    Get-Help Invoke-Pester -ShowWindow #search for examples
    

The topic ‘Capture the Executing output’ is closed to new replies.

denizli escort samsun escort muğla escort ataşehir escort kuşadası escort