Skip to content

Improve BeTrue assertion #1316

@t3mi

Description

@t3mi

1. General summary of the issue

I understand that examples specified below is how PowerShell works but it's not so obvious what assertion to use to make a proper check against the $true value even from the Should page. It would be helpful at least for BeTrue assertion to have a proper compare check.

Describe "Check if Truthy" {

    It "False as a string" {
        'False' | Should -Be $true
    }

    It "False as a string" {
        'False' | Should -BeTrue
    }

    It "Any string" {
        'Whatever' | Should -Be $true
    }

    It "Any string" {
        'Whatever' | Should -BeExactly $true
    }

    It "Any string" {
        'Whatever' | Should -BeTrue
    }
}

2. Describe Your Environment

Pester version     : 4.8.1 C:\Program Files\WindowsPowerShell\Modules\Pester\4.8.1\Pester.psd1
PowerShell version : 5.1.17763.316
OS version         : Microsoft Windows NT 10.0.17763.0

3. Expected Behavior

Tests must fail.

4.Current Behavior

Tests passed.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions