Format-Pester only generating Summary View from Pester results
ChrisLynchHPE opened this issue · 5 comments
I am trying to figure out why Format-Pester is only creating a Summary View of the Pester results of my Smoke Test script. The contents of the Smoke Test script follow this cadence:
Describe
Context
It
It
It
...
Context
It
It
Context
It
Describe
It
Describe
It
I call my Smoke Test script with the following:
([String]$PesterScriptSource = '{0}\Build Scripts\Pester Scripts' -f $LibrarySource) | Write-Verbose
([String]$DateStamp = [DateTime]::UtcNow.ToString('yyyyMMdd.HHmmss')) | Write-Verbose
([String]$PesterResultsFile = 'SmokeTestResults_{0}' -f $DateStamp) | Write-Verbose
Invoke-Pester -Tag SmokeTest -Script $PesterScriptSource -Passthru | Format-Pester -Path ($PesterScriptSource + '\Results') -Format HTML,Word -BaseFileName $PesterResultsFile
However, when looking at the TEXT file Format-Pester creates, I see basically a summary report:
Table of Contents
------------------------------------------------------------------------------------------------------------------------
1. Results summary
1. Results summary
------------------------------------------------------------------------------------------------------------------------
Total Tests Passed Tests Failed Tests Skipped Tests Pending Tests
----------- ------------ ------------ ------------- -------------
28 28 0 0 0
My Windows 10 host $PSVerionTable
[PS] C:\Users\me> $PSVersionTable
Name Value
---- -----
PSVersion 5.1.14393.0
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.14393.0
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
Here are the loaded Modules, minus the module I am using Pester to test with:
[PS] C:\Users\clynch.DOCTORS-LAB> get-module
ModuleType Version Name ExportedCommands
---------- ------- ---- ----------------
Binary 1.0.0.0 CimCmdlets {Export-BinaryMiLog, Get-CimAssociatedInstance, Get-CimCla...
Script 1.3.1 Format-Pester Format-Pester
Script 1.1.3.15 FormatPX {Format-Custom, Format-Default, Format-List, Format-Table...}
Manifest 3.1.0.0 Microsoft.PowerShell.Management {Add-Computer, Add-Content, Checkpoint-Computer, Clear-Con...
Manifest 3.0.0.0 Microsoft.PowerShell.Security {ConvertFrom-SecureString, ConvertTo-SecureString, Get-Acl...
Manifest 3.1.0.0 Microsoft.PowerShell.Utility {Add-Member, Add-Type, Clear-Variable, Compare-Object...}
Manifest 3.0.0.0 Microsoft.WSMan.Management {Connect-WSMan, Disable-WSManCredSSP, Disconnect-WSMan, En...
Script 3.4.2 Pester {AfterAll, AfterEach, Assert-MockCalled, Assert-Verifiable...
Script 0.7.12.47 pscribo {BlankLine, Document, Export-Document, GlobalOption...}
Script 1.0.0.13 PSReadline {Get-PSReadlineKeyHandler, Get-PSReadlineOption, Remove-PS...
Binary 1.0.5.18 SnippetPx {Get-Snippet, Invoke-Snippet}
Am I "doing it wrong?" Am I missing something?
So, I looked at Format-Pester.ps1, and see at Line 332 your evaluation to generate the Sections seems to be a bit off. Are you sure that you meant to only generate sections within the report IF the FailedCount
root property of the $PesterResult
object was greater than 0?
When I change Line 332 from:
If (-not $PassedOnly.IsPresent) -and $PesterResult.FailedCount -gt 0) {
To:
If (-not $PassedOnly.IsPresent) { #-and $PesterResult.FailedCount -gt 0) {
The full report is created no matter the output type is (Word, HTML, or Text). However, pscribo
throws a number of exceptions:
PS] C:\temp> Format-pester -PesterResult $PesterResult -Format HTML,Word,Text
The property 'Type' cannot be found on this object. Verify that the property exists.
At C:\Program Files\WindowsPowerShell\Modules\pscribo\0.7.12.47\Src\Private\Document.Internal.ps1:101 char:21
+ if ($s.Type -like '*.Section') {
+ ~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], PropertyNotFoundException
+ FullyQualifiedErrorId : PropertyNotFoundStrict
The property 'Id' cannot be found on this object. Verify that the property exists.
At C:\Program Files\WindowsPowerShell\Modules\pscribo\0.7.12.47\Src\Plugins\OutHtml.ps1:51 char:17
+ if ($s.Id.Length -gt 40) { $sectionId = '{0}[..]' -f $s.I ...
+ ~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], PropertyNotFoundException
+ FullyQualifiedErrorId : PropertyNotFoundStrict
The property 'Type' cannot be found on this object. Verify that the property exists.
At C:\Program Files\WindowsPowerShell\Modules\pscribo\0.7.12.47\Src\Plugins\OutHtml.ps1:55 char:13
+ WriteLog -Message ($localized.PluginProcessingSection -f ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], PropertyNotFoundException
+ FullyQualifiedErrorId : PropertyNotFoundStrict
The property 'Type' cannot be found on this object. Verify that the property exists.
At C:\Program Files\WindowsPowerShell\Modules\pscribo\0.7.12.47\Src\Plugins\OutHtml.ps1:55 char:13
+ WriteLog -Message ($localized.PluginProcessingSection -f ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], PropertyNotFoundException
+ FullyQualifiedErrorId : PropertyNotFoundStrict
Directory: C:\temp
Mode LastWriteTime Length Name
---- ------------- ------ ----
-a---- 8/19/2016 1:40 PM 12016 Pester_Results.html
The property 'Id' cannot be found on this object. Verify that the property exists.
At C:\Program Files\WindowsPowerShell\Modules\pscribo\0.7.12.47\Src\Plugins\OutWord.ps1:50 char:17
+ if ($s.Id.Length -gt 40) { $sectionId = '{0}[..]' -f $s.I ...
+ ~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], PropertyNotFoundException
+ FullyQualifiedErrorId : PropertyNotFoundStrict
The property 'Type' cannot be found on this object. Verify that the property exists.
At C:\Program Files\WindowsPowerShell\Modules\pscribo\0.7.12.47\Src\Plugins\OutWord.ps1:54 char:13
+ WriteLog -Message ($localized.PluginProcessingSection -f ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], PropertyNotFoundException
+ FullyQualifiedErrorId : PropertyNotFoundStrict
The property 'Type' cannot be found on this object. Verify that the property exists.
At C:\Program Files\WindowsPowerShell\Modules\pscribo\0.7.12.47\Src\Plugins\OutWord.ps1:54 char:13
+ WriteLog -Message ($localized.PluginProcessingSection -f ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], PropertyNotFoundException
+ FullyQualifiedErrorId : PropertyNotFoundStrict
-a---- 8/19/2016 1:40 PM 36301 Pester_Results.docx
The property 'Id' cannot be found on this object. Verify that the property exists.
At C:\Program Files\WindowsPowerShell\Modules\pscribo\0.7.12.47\Src\Plugins\OutText.ps1:43 char:17
+ if ($s.Id.Length -gt 40) { $sectionId = '{0}[..]' -f $s.I ...
+ ~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], PropertyNotFoundException
+ FullyQualifiedErrorId : PropertyNotFoundStrict
The property 'Type' cannot be found on this object. Verify that the property exists.
At C:\Program Files\WindowsPowerShell\Modules\pscribo\0.7.12.47\Src\Plugins\OutText.ps1:47 char:13
+ WriteLog -Message ($localized.PluginProcessingSection -f ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], PropertyNotFoundException
+ FullyQualifiedErrorId : PropertyNotFoundStrict
The property 'Type' cannot be found on this object. Verify that the property exists.
At C:\Program Files\WindowsPowerShell\Modules\pscribo\0.7.12.47\Src\Plugins\OutText.ps1:47 char:13
+ WriteLog -Message ($localized.PluginProcessingSection -f ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], PropertyNotFoundException
+ FullyQualifiedErrorId : PropertyNotFoundStrict
-a---- 8/19/2016 1:40 PM 20344 Pester_Results.txt
Hello @ChrisLynchHPE , thanks for your feedback!
You're right, i've got the same issue when there's no failed test... Sorry for the lack of testing...
The solution you provide seems to be the good one. I've pushed a new version (1.3.3) on Github and the powershell Gallery.
What's weird is that I don't have any error with PScribo, maybe @iainbrighton could have an idea ?
Heh, "lack of testing"... That's a good one! Glad I could help.
As for PScribo, I didn't modify it in any way. I removed both modules, installed from PSGallary, and all is working as it should!
Thanks for testing Format-Pester! ;-)
Did you find the module useful ?
Sorry for replying to this almost a year later, but yes, the module is extremely useful. It helps to generate readable reports.