diff --git a/Functions/Assertions/Set-TestInconclusive.ps1 b/Functions/Assertions/Set-TestInconclusive.ps1 index e01380e7a..a6ab8cfa1 100644 --- a/Functions/Assertions/Set-TestInconclusive.ps1 +++ b/Functions/Assertions/Set-TestInconclusive.ps1 @@ -51,6 +51,7 @@ function Set-TestInconclusive { .LINK https://github.com/pester/Pester/wiki/Set%E2%80%90TestInconclusive #> + [CmdletBinding()] param ( [string] $Message ) diff --git a/Functions/In.ps1 b/Functions/In.ps1 index b7552a1ad..177997c8b 100644 --- a/Functions/In.ps1 +++ b/Functions/In.ps1 @@ -16,11 +16,11 @@ The path that the execute block will be executed in. The script to be executed in the path provided. #> - -param( - $path, - [ScriptBlock] $execute -) + [CmdletBinding()] + param( + $path, + [ScriptBlock] $execute + ) Assert-DescribeInProgress -CommandName In $old_pwd = $pwd diff --git a/Functions/Mock.ps1 b/Functions/Mock.ps1 index 713724032..32d30245d 100644 --- a/Functions/Mock.ps1 +++ b/Functions/Mock.ps1 @@ -154,7 +154,7 @@ It about_Should about_Mocking #> - + [CmdletBinding()] param( [string]$CommandName, [ScriptBlock]$MockWith={}, @@ -405,6 +405,7 @@ Assert-VerifiableMocks This will not throw an exception because the mock was invoked. #> + [CmdletBinding()]param() Assert-DescribeInProgress -CommandName Assert-VerifiableMocks $unVerified=@{} diff --git a/Functions/SetupTeardown.ps1 b/Functions/SetupTeardown.ps1 index 1e2314fbc..f3a95ca17 100644 --- a/Functions/SetupTeardown.ps1 +++ b/Functions/SetupTeardown.ps1 @@ -15,6 +15,15 @@ function BeforeEach .LINK about_BeforeEach_AfterEach #> + [CmdletBinding()] + param + ( + # the scriptblock to execute + [Parameter(Mandatory = $true, + Position = 1)] + [Scriptblock] + $Scriptblock + ) Assert-DescribeInProgress -CommandName BeforeEach } @@ -35,6 +44,15 @@ function AfterEach .LINK about_BeforeEach_AfterEach #> + [CmdletBinding()] + param + ( + # the scriptblock to execute + [Parameter(Mandatory = $true, + Position = 1)] + [Scriptblock] + $Scriptblock + ) Assert-DescribeInProgress -CommandName AfterEach } @@ -53,6 +71,15 @@ function BeforeAll .LINK about_BeforeEach_AfterEach #> + [CmdletBinding()] + param + ( + # the scriptblock to execute + [Parameter(Mandatory = $true, + Position = 1)] + [Scriptblock] + $Scriptblock + ) Assert-DescribeInProgress -CommandName BeforeAll } @@ -71,6 +98,15 @@ function AfterAll .LINK about_BeforeEach_AfterEach #> + [CmdletBinding()] + param + ( + # the scriptblock to execute + [Parameter(Mandatory = $true, + Position = 1)] + [Scriptblock] + $Scriptblock + ) Assert-DescribeInProgress -CommandName AfterAll } diff --git a/Functions/TestDrive.ps1 b/Functions/TestDrive.ps1 index 21dbdfac2..9a02e8876 100644 --- a/Functions/TestDrive.ps1 +++ b/Functions/TestDrive.ps1 @@ -130,7 +130,10 @@ function Remove-TestDrive { } function Setup { - #included for backwards compatibility + <# + .SYNOPSIS + This command is included in the Pester Mocking framework for backwards compatibility. You do not need to call it directly. + #> param( [switch]$Dir, [switch]$File, diff --git a/Pester.Tests.ps1 b/Pester.Tests.ps1 index 9b34f98dd..ef95a213c 100644 --- a/Pester.Tests.ps1 +++ b/Pester.Tests.ps1 @@ -115,6 +115,23 @@ if ($PSVersionTable.PSVersion.Major -ge 3) } } +Describe 'Public API' { + It 'all non-deprecated, non-internal public commands use CmdletBinding' { + $r = Get-Command -Module Pester | + ? { $_.CommandType -ne 'Alias' } | # Get-Command outputs aliases in PowerShell 2 + ? { -not $_.CmdletBinding } | + % { $_.Name } | + ? { + @( + 'Get-TestDriveItem' # deprecated in 4.0 + 'SafeGetCommand' # Pester internal + 'Setup' # deprecated + ) -notcontains $_ + } + $r | Should beNullOrEmpty + } +} + Describe 'Style rules' { $pesterRoot = (Get-Module Pester).ModuleBase