Improve unique naming for tests (#17043)

This commit is contained in:
James Truher [MSFT]
2022-03-23 09:24:10 -07:00
committed by GitHub
parent 74a51aa16e
commit b3632eda46
5 changed files with 24 additions and 23 deletions
@@ -526,7 +526,7 @@ Describe 'method conversion' -Tags 'CI' {
}
Describe 'float/double precision when converting to string' -Tags "CI" {
It "<SourceType>-to-[string] conversion in PowerShell should use the precision specifier <Format>" -TestCases @(
It "<SourceType>-to-[string] conversion in PowerShell should use the precision specifier <Format> (<ToStringResult>)" -TestCases @(
@{ SourceType = [double]; Format = "G15"; ValueScript = { 1.1 * 3 }; StringConversionResult = "3.3"; ToStringResult = "3.3000000000000003" }
@{ SourceType = [double]; Format = "G15"; ValueScript = { 1.1 * 6 }; StringConversionResult = "6.6"; ToStringResult = "6.6000000000000005" }
@{ SourceType = [double]; Format = "G15"; ValueScript = { [System.Math]::E }; StringConversionResult = [System.Math]::E.ToString("G15"); ToStringResult = [System.Math]::E.ToString() }
@@ -551,7 +551,8 @@ Describe 'get-help other tests' -Tags "CI" {
$x = Get-Help helpFunc11 -det
$x.Parameters.parameter | ForEach-Object {
It '$_.description' { $_.description[0].text | Should -Match "^$($_.Name)\s+help" }
$dText = $_.description[0].text
It ('$_.description ({0})' -f $title) { $dText | Should -Match "^$($_.Name)\s+help" }
}
}
@@ -145,7 +145,7 @@ Describe "Remove-Module -Name | -FullyQualifiedName | -ModuleInfo" -Tags "CI" {
}
}
It "Remove-Module -FullyQualifiedName <FullyQualifiedName>" -TestCases $removeModuleByFQNTestCases {
It "Remove-Module -FullyQualifiedName <FqnToRemove>" -TestCases $removeModuleByFQNTestCases {
param([Microsoft.PowerShell.Commands.ModuleSpecification[]]$FqnToRemove, [string[]]$ShouldBeRemoved, [string[]]$ShouldBePresent)
(Get-Module -Name "Bar", "Baz", "Foo").Name | Should -BeExactly "Bar", "Baz", "Foo", "Foo"
@@ -161,7 +161,7 @@ Describe "Remove-Module -Name | -FullyQualifiedName | -ModuleInfo" -Tags "CI" {
}
}
It "Remove-Module -FullyQualifiedName <FullyQualifiedName> (Error cases)" -TestCases $removeModuleByFQNErrorTestCases {
It "Remove-Module -FullyQualifiedName <FqnToRemove> (Error cases)" -TestCases $removeModuleByFQNErrorTestCases {
param([Microsoft.PowerShell.Commands.ModuleSpecification[]]$FqnToRemove, [string[]]$ShouldBeRemoved, [string[]]$ShouldBePresent)
(Get-Module -Name "Bar", "Baz", "Foo").Name | Should -BeExactly "Bar", "Baz", "Foo", "Foo"
@@ -177,7 +177,7 @@ Describe "Remove-Module -Name | -FullyQualifiedName | -ModuleInfo" -Tags "CI" {
}
}
It "Remove-Module -ModuleInfo <ModuleInfo>" -TestCases $removeModuleByFQNTestCases {
It "Remove-Module -ModuleInfo <FqnToRemove>" -TestCases $removeModuleByFQNTestCases {
param([Microsoft.PowerShell.Commands.ModuleSpecification[]]$FqnToRemove, [string[]]$ShouldBeRemoved, [string[]]$ShouldBePresent)
(Get-Module -Name "Bar", "Baz", "Foo").Name | Should -BeExactly "Bar", "Baz", "Foo", "Foo"
@@ -56,7 +56,7 @@ Describe "Get-Date DRT Unit Tests" -Tags "CI" {
}
# The 'week of year' test cases is from https://en.wikipedia.org/wiki/ISO_week_date
It "using -uformat 'V' produces the correct output" -TestCases @(
It "using -uformat 'V' produces the correct output (<date>:<week>)" -TestCases @(
@{date="1998-01-02"; week = "01"},
@{date="1998-01-03"; week = "01"},
@{date="2003-01-03"; week = "01"},
@@ -98,7 +98,7 @@ Describe "Get-Date DRT Unit Tests" -Tags "CI" {
}
# Using the same test cases as V for ISO week date component parity, plus some more esoteric ones
It "using -uformat 'G' produces the correct output" -TestCases @(
It "using -uformat 'G' produces the correct output (<date>:<year>)" -TestCases @(
@{date="0055-12-31"; year = "0055"},
@{date="0325-01-01"; year = "0325"},
@{date="0777-01-01"; year = "0776"},
@@ -143,7 +143,7 @@ Describe "Get-Date DRT Unit Tests" -Tags "CI" {
}
# Using the same test cases as V for ISO week date component parity, plus some more esoteric ones
It "using -uformat 'g' produces the correct output" -TestCases @(
It "using -uformat 'g' produces the correct output (<date>:<yy>" -TestCases @(
@{date="0055-12-31"; yy = "55"},
@{date="0325-01-01"; yy = "25"},
@{date="0777-01-01"; yy = "76"},
@@ -188,7 +188,7 @@ Describe "Get-Date DRT Unit Tests" -Tags "CI" {
}
# Using the same test cases as V for ISO week date component parity
It "using -uformat 'u' produces the correct output" -TestCases @(
It "using -uformat 'u' produces the correct output (<date>:<dayOfWeek>)" -TestCases @(
@{date="1998-01-02"; dayOfWeek = "5"},
@{date="1998-01-03"; dayOfWeek = "6"},
@{date="2003-01-03"; dayOfWeek = "5"},
@@ -228,7 +228,7 @@ Describe "Get-Date DRT Unit Tests" -Tags "CI" {
param($date, $dayOfWeek)
Get-Date -Date $date -UFormat %u | Should -BeExactly $dayOfWeek
}
It "Passing '<name>' to -uformat produces a descriptive error" -TestCases @(
It "Passing '<name>' to -uformat produces a descriptive error (<errorId>)" -TestCases @(
@{ name = "`$null" ; value = $null; errorId = "ParameterArgumentValidationErrorNullNotAllowed" }
@{ name = "empty string"; value = ""; errorId = "ParameterArgumentValidationErrorEmptyStringNotAllowed" }
) {
@@ -286,11 +286,11 @@ Describe "Get-Date" -Tags "CI" {
Get-Date -Date 0030-01-01T01:02:03.0004 -Format FileDateTime | Should -Be "00300101T0102030004"
}
It "-Format FileDateTimeUniversal works" {
It "-Format FileDateTimeUniversal works (1)" {
Get-Date -Date 0030-01-01T01:02:03.0004z -Format FileDateTimeUniversal | Should -Be "00300101T0102030004Z"
}
It "-Format FileDateTimeUniversal works" {
It "-Format FileDateTimeUniversal works (2)" {
Get-Date -Date 0030-01-01T01:02:03.0004z -Format FileDateUniversal | Should -Be "00300101Z"
}
@@ -324,7 +324,7 @@ Describe "Get-Date" -Tags "CI" {
$timeDifference.Ticks | Should -BeLessThan 10000
}
It "-UnixTimeSeconds works" -TestCases @(
It "-UnixTimeSeconds works (<Expected>)" -TestCases @(
@{ UnixTimeSeconds = 1577836800; Expected = [System.DateTimeOffset]::FromUnixTimeSeconds(1577836800).LocalDateTime },
@{ UnixTimeSeconds = 0; Expected = [System.DateTimeOffset]::UnixEpoch.LocalDateTime },
@{ UnixTimeSeconds = -1; Expected = [System.DateTimeOffset]::FromUnixTimeSeconds(-1).LocalDateTime }
@@ -360,7 +360,7 @@ Describe "Get-Date -UFormat tests" -Tags "CI" {
$timeZone1 = [String]::Format("{0:+00;-00}", [Timezone]::CurrentTimeZone.GetUtcOffset( $date1 ).Hours)
}
It "Get-Date -UFormat <format>" -TestCases @(
It "Get-Date -UFormat <format> (<result>)" -TestCases @(
# Some format specifiers is locale sensetive:
# - and tests work on EN-US only
# - and can not be full compatible with Unix 'date' utility.
@@ -18,12 +18,12 @@ Describe "BooleanParameterDCR Tests" -tags "CI" {
}
$tests = @(
@{ inputTest = 0; expected = $false },
@{ inputTest = 000; expected = $false },
@{ inputTest = 0x00; expected = $false },
@{ inputTest = 0.00; expected = $false }
@{ inputTest = 0; expected = $false; iteration = 1 },
@{ inputTest = 000; expected = $false; iteration = 2 },
@{ inputTest = 0x00; expected = $false; iteration = 3 },
@{ inputTest = 0.00; expected = $false; iteration = 4 }
)
It "Test that passing zero works as the value for a Switch parameter, inputTest:<inputTest>,expect:<expected>" -TestCases $tests {
It "Test <iteration> that passing zero works as the value for a Switch parameter, inputTest:<inputTest>,expect:<expected>" -TestCases $tests {
param ( $inputTest, $expected )
[bool]$switchTestParam = $inputTest
$result = ParserTestSwitchCmdlet -switchParam:$switchTestParam
@@ -31,11 +31,11 @@ Describe "BooleanParameterDCR Tests" -tags "CI" {
}
$tests = @(
@{ inputTest = $(1 -eq 1); expected = $true },
@{ inputTest = $true; expected = $true },
@{ inputTest = $TRUE; expected = $true }
@{ inputTest = $(1 -eq 1); expected = $true; iteration = 1},
@{ inputTest = $true; expected = $true; iteration = 2},
@{ inputTest = $TRUE; expected = $true; iteration = 3}
)
It "Test that $true is accepted as a true value for Switch parameters, inputTest:<inputTest>,expect:<expected>" -TestCases $tests {
It "Test <iteration> that $true is accepted as a true value for Switch parameters, inputTest:<inputTest>,expect:<expected>" -TestCases $tests {
param ( $inputTest, $expected )
[bool]$switchTestParam = $inputTest
$result = ParserTestSwitchCmdlet -switchParam:$switchTestParam