Skip to content

Add array and hastable assertions#804

Closed
stuartleeks wants to merge 5 commits intopester:masterfrom
stuartleeks:ArrayAndHastableAssertions
Closed

Add array and hastable assertions#804
stuartleeks wants to merge 5 commits intopester:masterfrom
stuartleeks:ArrayAndHastableAssertions

Conversation

@stuartleeks
Copy link
Copy Markdown

Based on a tweet from @it-praktyk (https://twitter.com/ITpraktyk/status/889585074760552453), I'm submitting a PR with the array and hashtable assertions from my pester extensions.

I used them in my posh-HumpCompletion tests here: https://github.com/stuartleeks/posh-HumpCompletion/blob/master/posh-HumpCompletion.tests.ps1#L64

Let me know what you think, and whether there are any changes you'd recommend :-)

@nohwnd
Copy link
Copy Markdown
Member

nohwnd commented Jul 28, 2017 via email

@nohwnd
Copy link
Copy Markdown
Member

nohwnd commented Jul 28, 2017

@nohwnd nohwnd added this to the v4.1 milestone Jul 28, 2017
@stuartleeks stuartleeks force-pushed the ArrayAndHastableAssertions branch from 2bd1847 to 018431a Compare July 28, 2017 06:25
@stuartleeks
Copy link
Copy Markdown
Author

stuartleeks commented Jul 28, 2017

Thanks @nohwnd - I look forward to discussing this more with you when the 4.0 release is out :-)

@stuartleeks stuartleeks force-pushed the ArrayAndHastableAssertions branch from 018431a to baad719 Compare July 28, 2017 08:32
@stuartleeks
Copy link
Copy Markdown
Author

@nohwnd - I've just updated the PR and it looks like the build is passing now: https://build.powershell.org/viewLog.html?buildId=10884&tab=buildResultsDiv&buildTypeId=Pester_TestPesterOnPowerShellV2

@it-praktyk
Copy link
Copy Markdown
Contributor

#121 - is it related?

@stuartleeks
Copy link
Copy Markdown
Author

From scanning the thread on that issue, it looks like the OP wants to test for the existence of an element in an array. This PR is intended to allow comparison of the full array or hashtable, so I think that they are slightly different cases.

@it-praktyk
Copy link
Copy Markdown
Contributor

Thx, I just found it in a middle of the night so wasn't sure.

@dlwyatt
Copy link
Copy Markdown
Member

dlwyatt commented Aug 13, 2017

In v4, Should Be already compares arrays, so we may not need a separate operator for that.

@DarkLite1
Copy link
Copy Markdown
Contributor

DarkLite1 commented Oct 5, 2017

Thanks @dlwyatt , I didn't know this. This feature, comparing of Arrays is not in the Help for the CmdLet Should in version 4.0.8:

PS C:\> Get-Help Should

NAME
    Should
    
SYNOPSIS
    Should is a keyword what is used to define an assertion inside It block.
    
    
SYNTAX
    Should [[-LegacyArg1] <Object>] [[-LegacyArg2] <Object>] [[-LegacyArg3] <Object>] [-ActualValue <Object>] [<Common
    Parameters>]
    
    
DESCRIPTION
    Should is a keyword what is used to define an assertion inside the It block.
    Should provides assertion methods for verify assertion e.g. comparing objects.
    If assertion is not met the test fails and an exception is throwed up.
    
    Should can be used more than once in the It block if more than one assertion
    need to be verified. Each Should keywords need to be located in a new line.
    Test will be passed only when all assertion will be met (logical conjuction).
    

RELATED LINKS
    about_Should
    about_Pester 

REMARKS
    To see the examples, type: "get-help Should -examples".
    For more information, type: "get-help Should -detailed".
    For technical information, type: "get-help Should -full".
    For online help, type: "get-help Should -online"



PS C:\> Get-Help Should -Examples

NAME
    Should
    
SYNOPSIS
    Should is a keyword what is used to define an assertion inside It block.

Might be something for #876

@it-praktyk it-praktyk modified the milestones: v4.1, 4.2 Nov 11, 2017
@it-praktyk
Copy link
Copy Markdown
Contributor

@DarkLite1, I assume that it was described in the updated version of about_Should. Can you verify?

Help for Should itself is very limited intentionally.

@nohwnd nohwnd removed this from the 4.3 milestone May 6, 2018
@it-praktyk
Copy link
Copy Markdown
Contributor

The label 'Documentation' added - to remember to add information about Should -Be and arrays to 'about_Should_help'

@nohwnd
Copy link
Copy Markdown
Member

nohwnd commented Dec 12, 2018

@stuartleeks Stuart thanks for your contribution, but I won't merge this. I plan to move Assert into Pester and use the functionality developed there to give Pester collection, hashtable, and dictionary comparing assertions. Hope this will give us more options such as ordered, non-ordered, each and any.

@nohwnd nohwnd closed this Dec 12, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants