pester / Pester

Pester is the ubiquitous test and mock framework for PowerShell.
https://pester.dev/
Other
3.11k stars 473 forks source link

Pester 4.6.0 test failing when testing for psm1 file in psd1 file #1237

Closed ghost closed 3 years ago

ghost commented 5 years ago

1. General summary of the issue

An It test looking for a PowerShell module (psm1) file in a PowerShell manifest (psd1) file is failing.

2. Describe Your Environment

(Details obtained manually) Pester 4.6.0 PowerShell 5.1.17763.134 Desktop Edition Windows 10 Enterprise version 1809.

(Details obtained using $bugReport script) Pester version : 4.6.0 C:\Program Files\WindowsPowerShell\Modules\Pester\4.6.0\Pester.psd1 PowerShell version : 5.1.17763.134 OS version : Microsoft Windows NT 10.0.17763.0

3. Expected Behavior

Test output using Pester 3.4.0 and RootModule element

Describing Podcast-NoAgenda Module Tests [+] has the root module Podcast-NoAgenda.psm1 32ms [+] has the manifest file Podcast-NoAgenda.psd1 13ms Tests completed in 45ms Passed: 2 Failed: 0 Skipped: 0 Pending: 0 Inconclusive: 0

4.Current Behavior

Test output using Pester 4.6.0 and RootModule element or ModuleToProcess element

Executing all tests in 'D:\workspace_powershell\Pester\Pluralsight Testing PowerShell with Pester\Podcast-NoAgenda.Module.Ver01.Tests.ps1'

Executing script D:\workspace_powershell\Pester\Pluralsight Testing PowerShell with Pester\Podcast-NoAgenda.Module.Ver01.Tests.ps1

Describing Podcast-NoAgenda Module Tests [+] has the root module Podcast-NoAgenda.psm1 2ms [-] has the manifest file Podcast-NoAgenda.psd1 7ms Expected 'Podcast-NoAgenda.psm1' to be found in collection D:\workspace_powershell\Pester\Pluralsight Testing PowerShell with Pester\Podcast-NoAgenda.psd1, but it was not found. 32: 'D:\workspace_powershell\Pester\Pluralsight Testing PowerShell with Pester\Podcast-NoAgenda.psd1' | Should Contain 'Podcast-NoAgenda.psm1' at Invoke-LegacyAssertion, C:\Program Files\WindowsPowerShell\Modules\Pester\4.6.0\Functions\Assertions\Should.ps1: line 166 at , D:\workspace_powershell\Pester\Pluralsight Testing PowerShell with Pester\Podcast-NoAgenda.Module.Ver01.Tests.ps1: line 32 Tests completed in 77ms Tests Passed: 1, Failed: 1, Skipped: 0, Pending: 0, Inconclusive: 0

5. Possible Solution

6. Context

nohwnd commented 5 years ago

I see in the stack that legacy assertions (the ones like Should Be where Be is a positional parameter and not -Be a named parameter) are used. Using the new syntax with dashes, might help. Otherwise I will need to debug this later :)

ghost commented 5 years ago

Hi, I get the same result with .psd1 | Should -Contain .psm1. It does work using Pester 3.4.0 with RootModule = .psm1 in the psd1 file.

Describing Podcast-NoAgenda Module Tests [+] has the root module Podcast-NoAgenda.psm1 4ms [-] has the manifest file Podcast-NoAgenda.psd1 8ms Expected 'Podcast-NoAgenda.psm1' to be found in collection D:\workspace_powershell\Pester\Pluralsight Testing PowerShell with Pester\Podcast-NoAgenda.psd1, but it was not found. 32: 'D:\workspace_powershell\Pester\Pluralsight Testing PowerShell with Pester\Podcast-NoAgenda.psd1' | Should -Contain 'Podcast-NoAgenda.psm1' at , D:\workspace_powershell\Pester\Pluralsight Testing PowerShell with Pester\Podcast-NoAgenda.Module.Ver01.Tests.ps1: line 32