Skip to content

Way forward for Should? #1423

@nohwnd

Description

@nohwnd

Should assertions have multiple quirks and pain points, here is a not-complete list:

  • -Be does too much, so it is hard to understand what is happening
  • Enumeration via pipeline complicates a lot of things and -Be has special logic to revert this, which does not always work
  • It is difficult to apply seperate special behavior for different types of data (e.g. Should -BeFalse -AllowNull -AllowTypeCast -FalseStringAsFalse, Should -BeString -CaseSensitive, Should -BeCollection -All { $_ -like "*file.ps1" }) because parameter sets limited to 32 parameter sets per function

I researched the various limitations of Should by writing a separate module Assert which has nice functionality but is not used often because people are not aware of it. I think it would be wort it to merge the functionality into Pester and fix some of the quirks finally. But I am wondering what ways forward I actually have.

There are few more limitations:

  • How to export the Should-* functions without triggering Verb warning? (Pester is getting around this by using single word functions at the moment).
  • How to ensure backward compatibility? (probably Should -Be has to remain in place while Should-Be is added)
  • Should this change be done in v5? (if it is parallel then we can do it as non-breaking change).

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions