From 9cebf9a4f007beeb924f1cbf783781112f5fad4c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Asbj=C3=B8rn=20Mangabat=20Bach=20Merling?= Date: 2017年6月29日 14:27:22 +0200 Subject: [PATCH 1/2] added -fixture and -name parameters to describe blocks --- .../Diagnostics/Comprehensive/PSGallery.Comprehensive.Tests.ps1 | 2 +- .../Diagnostics/Simple/PSGallery.Simple.Tests.ps1 | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Modules/OperationValidation/Diagnostics/Comprehensive/PSGallery.Comprehensive.Tests.ps1 b/Modules/OperationValidation/Diagnostics/Comprehensive/PSGallery.Comprehensive.Tests.ps1 index fc6d949..7505168 100644 --- a/Modules/OperationValidation/Diagnostics/Comprehensive/PSGallery.Comprehensive.Tests.ps1 +++ b/Modules/OperationValidation/Diagnostics/Comprehensive/PSGallery.Comprehensive.Tests.ps1 @@ -1,4 +1,4 @@ -Describe "E2E validation of PSGallery" { +Describe "E2E validation of PSGallery" -fixture{ BeforeAll { $Repository = "InternalPSGallery" $ModuleName = "FormatTools" diff --git a/Modules/OperationValidation/Diagnostics/Simple/PSGallery.Simple.Tests.ps1 b/Modules/OperationValidation/Diagnostics/Simple/PSGallery.Simple.Tests.ps1 index f16b61a..b3128e0 100644 --- a/Modules/OperationValidation/Diagnostics/Simple/PSGallery.Simple.Tests.ps1 +++ b/Modules/OperationValidation/Diagnostics/Simple/PSGallery.Simple.Tests.ps1 @@ -1,4 +1,4 @@ -Describe "Simple Validation of PSGallery" { +Describe -name "Simple Validation of PSGallery" { It "The PowerShell Gallery should be responsive" { $request = [System.Net.WebRequest]::Create("http://psget/psgallery") $response = $Request.GetResponse() From 3d6c7ef420ee6d57682786fbbad247ecf49c3456 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Asbj=C3=B8rn=20Mangabat=20Bach=20Merling?= Date: 2017年6月29日 14:31:23 +0200 Subject: [PATCH 2/2] Get name property regardsless of it is named or positional --- .../OperationValidation/OperationValidation.psm1 | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/Modules/OperationValidation/OperationValidation.psm1 b/Modules/OperationValidation/OperationValidation.psm1 index dd697d2..5e36fc6 100644 --- a/Modules/OperationValidation/OperationValidation.psm1 +++ b/Modules/OperationValidation/OperationValidation.psm1 @@ -89,8 +89,19 @@ function Get-TestFromScript }, $true) | ForEach-Object { # This is the name of the 'describe' block - $describeName = ($_.CommandElements | Where-Object { $_.StaticType.name -eq 'string' })[1].SafeGetValue() - + for ($x = 0; $x -lt $_.CommandElements.Count; $x++) + { + #Name parameter is named + if ($_.CommandElements[$x] -is [System.Management.Automation.Language.CommandParameterAst] -and $_.CommandElements[$x].ParameterName -eq 'Name') + { + $describeName = $_.CommandElements[$x + 1].value + } + #if we have a string without a parameter name, return first hit. Name parameter is at position 0. + ElseIf (($_.CommandElements[$x] -is [System.Management.Automation.Language.StringConstantExpressionAst]) -and ($_.CommandElements[$x - 1] -is [System.Management.Automation.Language.StringConstantExpressionAst])) + { + $describeName = $_.CommandElements[$x].value + } + } $item = [PSCustomObject][ordered]@{ Name = $describeName Tags = @()

AltStyle によって変換されたページ (->オリジナル) /