Capture the Executing output

Welcome Forums Pester Capture the Executing output

Viewing 2 reply threads
  • Author
    • #112339
      Topics: 41
      Replies: 56
      Points: 119
      Rank: Participant


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

      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
      Senior Moderator
      Topics: 9
      Replies: 1265
      Points: 4,582
      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
Viewing 2 reply threads
  • The topic ‘Capture the Executing output’ is closed to new replies.