Skip to content

Pester for Non-Terminating Error #366

@dotps1

Description

@dotps1

I reviewed the Should Wiki Page, and i apologize if i missed how to use this, but i was working with some error handling, and i want to Pester for non terminating errors as well as Exceptions. Basically, i have some tests in a function that are in the Process block, and i still want the End block to process, so in this case i want to use Write-Error rather then Throw, so, in my pester assertion, i want to make sure the Catch block is being hit, and the Write-Error is being executed, and im not sure how to do that.

It 'Error should be raised' {
     My-FunctionThatWritesErrorForInvalidPath -Path '.\InvalidPath' | Should #Here is where im lost, maybe Should Error would be nice.
}

I hope that makes sense and im sorry if im just using Write-Error incorrectly, and i could use the 'Should Throw' assertion.

thanks for any help.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions