I recently saw that the integration tests 'Should return $true when Test-DscConfiguration is run' that is part of the integration tests template does not fail as expected.
PS > $result = Test-DscConfiguration -Verbose
VERBOSE: Perform operation 'Invoke CimMethod' with following parameters, ''methodName' = TestConfiguration,'className'
= MSFT_DSCLocalConfigurationManager,'namespaceName' = root/Microsoft/Windows/DesiredStateConfiguration'.
VERBOSE: An LCM method call arrived from computer SQLTEST with user sid S-1-5-21-2246212248-426023572-517575333-1441.
VERBOSE: [SQLTEST]: LCM: [ Start Test ]
VERBOSE: [SQLTEST]: LCM: [ Start Resource ] [[PSModule]InstallModule]
VERBOSE: [SQLTEST]: LCM: [ Start Test ] [[PSModule]InstallModule]
VERBOSE: [SQLTEST]: [[PSModule]InstallModule] Determining if the module 'posh-git' is in the
desired state.
VERBOSE: [SQLTEST]: [[PSModule]InstallModule] Getting the current state of the module
'posh-git'.
VERBOSE: [SQLTEST]: [[PSModule]InstallModule] Begin invoking Get-Module 'posh-git'.
VERBOSE: [SQLTEST]: [[PSModule]InstallModule] Populating RepositorySourceLocation property
for module posh-git.
VERBOSE: [SQLTEST]: [[PSModule]InstallModule] Loading module from path 'C:\Program
Files\WindowsPowerShell\Modules\posh-git\0.7.3\posh-git.psm1'.
VERBOSE: [SQLTEST]: [[PSModule]InstallModule] Module 'posh-git 0.7.3' is found on the node.
VERBOSE: [SQLTEST]: [[PSModule]InstallModule] Module 'posh-git' is found on the node.
VERBOSE: [SQLTEST]: [[PSModule]InstallModule] Found the module path: 'C:\Program
Files\WindowsPowerShell\Modules\posh-git\0.7.3\PSGetModuleInfo.xml'.
VERBOSE: [SQLTEST]: [[PSModule]InstallModule] Resource 'posh-git' is in the desired state.
VERBOSE: [SQLTEST]: LCM: [ End Test ] [[PSModule]InstallModule] True in 2.6090 seconds.
VERBOSE: [SQLTEST]: LCM: [ End Resource ] [[PSModule]InstallModule]
VERBOSE: [SQLTEST]: LCM: [ End Test ] Completed processing test operation. The operation returned True.
VERBOSE: [SQLTEST]: LCM: [ End Test ] in 3.2500 seconds.
VERBOSE: Operation 'Invoke CimMethod' complete.
VERBOSE: Time taken for configuration job to complete is 3.348 seconds
PS > $result
True
PS > $result.Gettype()
IsPublic IsSerial Name BaseType
-------- -------- ---- --------
True True String System.Object
I prefer the former solution Test-DscConfiguration -Verbose | Should -Be 'True'. I will sen in a PR with that change, and if there is a better solution I will change to that.
I recently saw that the integration tests
'Should return $true when Test-DscConfiguration is run'
that is part of the integration tests template does not fail as expected.https://github.com/PowerShell/DscResource.Template/blob/f91a42580bb86642ac389abce5dc04d3f43f080e/Tests/Integration/integration_test_template.ps1#L108-L110
The reason is that
Test-DscConfiguration
returns a[System.String]
and not a[System.Boolean]
, so this test always passes regardless of outcome. Ii can be seen here on this line, it is reported False, but the test passes. https://ci.appveyor.com/project/johlju/sqlserverdsc/builds/23132521/job/vkxi4xq8jqke7ahf#L1198Verified it here too
So we should either change the line https://github.com/PowerShell/DscResource.Template/blob/f91a42580bb86642ac389abce5dc04d3f43f080e/Tests/Integration/integration_test_template.ps1#L109
to either
or