- This topic has 2 replies, 3 voices, and was last updated 1 year, 10 months ago by
September 21, 2018 at 3:57 pm #112339ParticipantTopics: 41Replies: 56Points: 119Rank: 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
September 21, 2018 at 5:33 pm #112366ParticipantTopics: 0Replies: 2Points: 22Rank: 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.
September 22, 2018 at 8:20 am #112451Senior ModeratorTopics: 9Replies: 1265Points: 4,582Rank: 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.