Capture the Executing output

Welcome Forums Pester Capture the Executing output

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

1 month ago.

  • Author
  • #112339

    Points: 0
    Rank: Member


    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

    Points: 0
    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

    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

    Points: 65
    Rank: Member

    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

You must be logged in to reply to this topic.