Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Formatting pester output to HTML document results in 'ClassID' cannot be found exception #36

Closed
ChrisLynchHPE opened this issue Jun 29, 2017 · 10 comments
Milestone

Comments

@ChrisLynchHPE
Copy link

I just updated pester, Format-Pester and PScribo (versions are noted below) on my Windows 10 1703 system to the current versions posted in PowerShellGallery, and when using Format-Pester to output HTML results, the exception is generated:

[PS] C:\temp\pester> Format-Pester -PesterResult $Results -Path .\ -Format HTML
The property 'ClassId' cannot be found on this object. Verify that the property exists.
At line:247 char:17
+ ...             [ref] $null = $tocBuilder.AppendFormat('<h1 class="{0}">{ ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], PropertyNotFoundException
    + FullyQualifiedErrorId : PropertyNotFoundStrict

[PS] C:\temp\pester> $error[0] | fl * -force


PSMessageDetails      :
Exception             : System.Management.Automation.PropertyNotFoundException: The property 'ClassId' cannot be found
                        on this object. Verify that the property exists.
                           at System.Management.Automation.Language.PSGetMemberBinder.GetAdaptedValue(Object obj,
                        String member)
                           at CallSite.Target(Closure , CallSite , Object )
                           at System.Dynamic.UpdateDelegates.UpdateAndExecute1[T0,TRet](CallSite site, T0 arg0)
                           at System.Management.Automation.Interpreter.DynamicInstruction`2.Run(InterpretedFrame frame)
                           at
                        System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame
                        frame)
TargetObject          :
CategoryInfo          : NotSpecified: (:) [], PropertyNotFoundException
FullyQualifiedErrorId : PropertyNotFoundStrict
ErrorDetails          :
InvocationInfo        : System.Management.Automation.InvocationInfo
ScriptStackTrace      : at OutHtmlTOC<Process>, <No file>: line 247
                        at OutHtml<Process>, <No file>: line 70
                        at Export-Document<Process>, <No file>: line 60
                        at Format-Pester, C:\Program
                        Files\WindowsPowerShell\Modules\Format-Pester\1.5.1\Public\Format-Pester.ps1: line 719
                        at <ScriptBlock>, <No file>: line 1
PipelineIterationInfo : {}

My pester test is just a very simple test that I wanted to validate nested contexts in a pester test run:

#pester nested context test with 4.0.3


describe "Nested Context Test with Pester 4.0.3" {

    context "Context #1" {

        it "will test foo" {

            'foo' | should be foo

        }

        context "nested contex 1" {

            it "will test foo again" {

                'foo' | should not be foo

            }

        }

    }
    
}

Output from Get-Module and $PSVersionTable:

[PS] C:\temp\pester> get-module

ModuleType Version    Name                                ExportedCommands
---------- -------    ----                                ----------------
Binary     1.0.0.0    CimCmdlets                          {Export-BinaryMiLog, Get-CimAssociatedInstance, Get-CimCla...
Script     1.5.1      Format-Pester                       Format-Pester
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     4.0.3      pester                              {AfterAll, AfterEach, AfterEachFeature, AfterEachScenario...}
Script     0.7.17.75  pscribo                             {BlankLine, Document, DocumentOption, Export-Document...}
Script     1.0.0.13   PSReadline                          {Get-PSReadlineKeyHandler, Get-PSReadlineOption, Remove-PS...

[PS] C:\temp\pester> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      5.1.15063.413
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.15063.413
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

I even commented out the nested context section, and I still get the same exception above. Any ideas?

@it-praktyk
Copy link
Collaborator

@ChrisLynchHPE , thank you for your feedback. We will investigate it soon.

@it-praktyk it-praktyk added the bug label Jun 29, 2017
@it-praktyk
Copy link
Collaborator

PS >Invoke-Pester Desktop:\foo.test.ps1 -Quiet -PassThru | format-pester -DumpPScriboObject -Language en-us | select -ExpandProperty TOC

Id                    Number Level Name
--                    ------ ----- ----
RESULTSSUMMARY        1          0 Results summary
DETAILSFORFAILEDTESTS 2          0 Details for failed tests
DETAILSFORPASSEDTESTS 3          0 Details for passed tests


PS >Invoke-Pester Desktop:\foo.test.ps1 -Quiet -PassThru | format-pester -DumpPScriboObject -Language en-us | select -ExpandProperty SECTIONS

Id                                   Name                     Type
--                                   ----                     ----
7dbd5eec-1cc0-4707-bb6f-e82497f9804c Table of Contents        PScribo.TOC
RESULTSSUMMARY                       Results summary          PScribo.Section
DETAILSFORFAILEDTESTS                Details for failed tests PScribo.Section
DETAILSFORPASSEDTESTS                Details for passed tests PScribo.Section

@it-praktyk
Copy link
Collaborator

@ChrisLynchHPE , my first impression is that issue exits in the PScribo module. To investigate it I need to update Format-Pester - I've found errors in assigning parameters to 'DumpPScriboObjectParamSet' .

I hope that I'll finish it before Monday.

As I see even if error is displayed html file is generated correctly.

@it-praktyk it-praktyk added this to the 1.6.0 milestone Jun 29, 2017
@it-praktyk
Copy link
Collaborator

It looks like resolved by iainbrighton/PScribo@9ab6faf .

CC: @iainbrighton

@iainbrighton
Copy link

@it-praktyk @equelin If that branch solves your issue, do I need to publish it to the PSGallery?

@it-praktyk
Copy link
Collaborator

I'll confirm it tonight.

@it-praktyk
Copy link
Collaborator

@iainbrighton, I tested Format-Pester with PScribo after iainbrighton/PScribo@9ab6faf. I can confirm that the issue reported by @ChrisLynchHPE is resolved - thank you.
I'm not sure an impact - even with displayed error messages html files were generated correctly (?). It's your decision about publishing the newer version of PScribo.

@it-praktyk
Copy link
Collaborator

@iainbrighton, do you have any plans to publish updated PScribo module soon? Thx.

@iainbrighton
Copy link

@it-praktyk I'll try and publish the dev branch to the Gallery later today or tomorrow 😄.

@it-praktyk
Copy link
Collaborator

Based on the README.md of PScribo it was corrected in the version 0.7.18.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants