diff --git a/Format-Pester/Format-Pester.psd1 b/Format-Pester/Format-Pester.psd1 index 3f8989c..90adcd5 100644 --- a/Format-Pester/Format-Pester.psd1 +++ b/Format-Pester/Format-Pester.psd1 @@ -14,7 +14,7 @@ RootModule = 'Format-Pester.psm1' # Version number of this module. # If you are increasing ModuleVersion please change also the values of variable 'ScriptVersion' in the Format-Pester.ps1 file # Verify also translations and increase the values of msg00 fields -ModuleVersion = '1.3.3' +ModuleVersion = '1.4.0' # ID used to uniquely identify this module GUID = 'daa609a5-1293-4f62-9467-1a120c529e87' diff --git a/Format-Pester/Public/Format-Pester.ps1 b/Format-Pester/Public/Format-Pester.ps1 index 8a711d6..a7ccd91 100644 --- a/Format-Pester/Public/Format-Pester.ps1 +++ b/Format-Pester/Public/Format-Pester.ps1 @@ -1,438 +1,477 @@ -Function Format-Pester { -<# - .SYNOPSIS - Document Pester's tests results into the selected format (HTML, Word, Text). - - .DESCRIPTION - Create documents in formats: HTML, Word, Text using PScribo PowerShell module. Documents are preformated to be human friendly. - Local Word installation is not needed to be installed on the computers were documents. - - Additional languages (other than en-US) can be used - please read info for translator on the project web page. - - .PARAMETER PesterResult - Specifies the Pester results Object - - .PARAMETER Format - Specifies the document format. Might be: - - Text - - HTML - - Word - - .PARAMETER Path - Specifies where the documents will be stored. Default is the path where is executed this function. - - .PARAMETER BaseFileName - Specifies the document name. Default is 'Pester_Results'. - - .PARAMETER Order - Specify what results need to be evaluated first - passed or failed - means that will be included on the top of report. - By default failed tests are evaluated first. - - .PARAMETER GroupResultsBy - Select how results should be groupped. Available options: Result, Result-Describe, Result-Describe-Context. - - .PARAMETER PassedOnly - Select to return information about passed tests only. - - .PARAMETER FailedOnly - Select to return information about failed tests only. - - .PARAMETER SummaryOnly - Select to return only summaries for tests only (sums of numbers passed/failed/etc. tests). - - .PARAMETER SkipTableOfContent - Select to skip adding table of content at the begining of document(s). - - .PARAMETER SkipSummary - Select to skip adding table with test summaries (sums of numbers passed/failed/etc. tests). - - .PARAMETER Language - Select language what need to be used for generated reports. - By default language is detected by Get-Culture with fallback to en-US if translation is not available. - - .PARAMETER Version - Use that parameter to display version of Format-Pester only. - This parameter can be used to verify translations. - - .EXAMPLE - Invoke-Pester -PassThru | Format-Pester -Path . -Format HTML,Word,Text -BaseFileName 'PesterResults' - - This command will document the results of the Pester's tests. - Documents will be stored in the current path and they will be available in 3 formats (.html,.docx and .txt). - - .LINK - https://github.com/equelin/Format-Pester - - .NOTES - Initial author: Erwan Quelin - - Credits/coauthors: - - Travis Plunk, github[at]ez13[dot]net - - Wojciech Sciesinski, wojciech[at]sciesinski[dot]net - - LICENSE - Licensed under the MIT License - https://github.com/equelin/Format-Pester/blob/master/LICENSE - - TODO - - Pester test need to be updated - yes, post factum TDD ;-) - - INPUTS, OUTPUTS need to be described - - #> - - [CmdletBinding(DefaultParameterSetName = 'AllParamSet')] - [OutputType([IO.FileInfo])] - Param ( - [Parameter(Mandatory = $true, Position = 0, ValueFromPipeline = $True, ValueFromPipelinebyPropertyName = $True, HelpMessage = 'Pester results Object', ParameterSetName = 'AllParamSet')] - [Parameter(Mandatory = $true, Position = 0, ValueFromPipeline = $True, ValueFromPipelinebyPropertyName = $True, HelpMessage = 'Pester results Object', ParameterSetName = 'PassedOnlyParamSet')] - [Parameter(Mandatory = $true, Position = 0, ValueFromPipeline = $True, ValueFromPipelinebyPropertyName = $True, HelpMessage = 'Pester results Object', ParameterSetName = 'FailedOnlyParamSet')] - [Parameter(Mandatory = $true, Position = 0, ValueFromPipeline = $True, ValueFromPipelinebyPropertyName = $True, HelpMessage = 'Pester results Object', ParameterSetName = 'SummaryOnlyParamSet')] - [Parameter(Mandatory = $false, Position = 0, ValueFromPipeline = $True, ValueFromPipelinebyPropertyName = $True, HelpMessage = 'Pester results Object', ParameterSetName = 'VersionOnlyParamSet')] - [Array]$PesterResult, - [Parameter(Mandatory = $true, HelpMessage = 'PScribo export format', ParameterSetName = 'AllParamSet')] - [Parameter(Mandatory = $true, ParameterSetName = 'PassedOnlyParamSet')] - [Parameter(Mandatory = $true, ParameterSetName = 'FailedOnlyParamSet')] - [Parameter(Mandatory = $true, ParameterSetName = 'SummaryOnlyParamSet')] - [Parameter(Mandatory = $false, ParameterSetName = 'VersionOnlyParamSet')] - [ValidateSet('Text', 'Word', 'HTML')] - [String[]]$Format, - [Parameter(Mandatory = $false, HelpMessage = 'PScribo export path', ParameterSetName = 'AllParamSet')] - [Parameter(Mandatory = $false, ParameterSetName = 'PassedOnlyParamSet')] - [Parameter(Mandatory = $false, ParameterSetName = 'FailedOnlyParamSet')] - [Parameter(Mandatory = $false, ParameterSetName = 'SummaryOnlyParamSet')] - [ValidateNotNullorEmpty()] - [String]$Path = (Get-Location -PSProvider FileSystem), - [ValidateNotNullorEmpty()] - [string]$BaseFileName = 'Pester_Results', - [Parameter(Mandatory = $false, ParameterSetName = 'AllParamSet')] - [ValidateSet('FailedFirst', 'PassedFirst')] - [String]$Order = 'FailedFirst', - [Parameter(Mandatory = $false, ParameterSetName = 'AllParamSet')] - [Parameter(Mandatory = $false, ParameterSetName = 'PassedOnlyParamSet')] - [Parameter(Mandatory = $false, ParameterSetName = 'FailedOnlyParamSet')] - [ValidateSet('Result', 'Result-Describe', 'Result-Describe-Context')] - [String]$GroupResultsBy = 'Result', - [Parameter(Mandatory = $false, ParameterSetName = 'PassedOnlyParamSet')] - [Switch]$PassedOnly, - [Parameter(Mandatory = $false, ParameterSetName = 'FailedOnlyParamSet')] - [Switch]$FailedOnly, - [Parameter(Mandatory = $false, ParameterSetName = 'SummaryOnlyParamSet')] - [switch]$SummaryOnly, - [Parameter(Mandatory = $false, ParameterSetName = 'AllParamSet')] - [Parameter(Mandatory = $false, ParameterSetName = 'PassedOnlyParamSet')] - [Parameter(Mandatory = $false, ParameterSetName = 'FailedOnlyParamSet')] - [Parameter(Mandatory = $false, ParameterSetName = 'SummaryOnlyParamSet')] - [Switch]$SkipTableOfContent, - [Parameter(Mandatory = $false, ParameterSetName = 'AllParamSet')] - [Parameter(Mandatory = $false, ParameterSetName = 'PassedOnlyParamSet')] - [Parameter(Mandatory = $false, ParameterSetName = 'FailedOnlyParamSet')] - [Switch]$SkipSummary, - [Parameter(Mandatory = $false, ParameterSetName = 'AllParamSet')] - [Parameter(Mandatory = $false, ParameterSetName = 'PassedOnlyParamSet')] - [Parameter(Mandatory = $false, ParameterSetName = 'FailedOnlyParamSet')] - [Parameter(Mandatory = $false, ParameterSetName = 'SummaryOnlyParamSet')] - [String]$Language = $($(Get-Culture).Name), - [Parameter(Mandatory = $false, ParameterSetName = 'VersionOnlyParamSet')] - [Switch]$Version - ) - - [Version]$ScriptVersion = "1.3.3" - - If ($Version.IsPresent) { - - Return $ScriptVersion.ToString() - - Break - - } - Else { - - if ($null -eq $PesterResult) { - - $MessageText = "Value of the parameter PesterResult can't be null or empty." - - Throw $MessageText - - } - - } - - Import-LocalizedData -FileName Format-Pester.psd1 -BindingVariable LocalizedStrings -UICulture $Language -ErrorAction SilentlyContinue - - If ([String]::IsNullOrEmpty($LocalizedStrings)) { - - Import-LocalizedData -FileName Format-Pester.psd1 -BindingVariable LocalizedStrings -UICulture 'en-US' -ErrorAction Stop - - [String]$MessageText = "{0} {1} {2}" -f $LocalizedStrings.msg27, $Language, $LocalizedStrings.msg28 - - Write-Verbose -Message $MessageText - - } - - If ($LocalizedStrings.msg00 -lt $ScriptVersion) { - - [String]$MessageText = "{0}" -f $LocalizedStrings.msg29 - - Write-Warning -Message $MessageText - - } - - - - #LocalizedStrings are not sorted alphabeticaly -even if you are using Sort-Object ! - #$LocalizedStrings - - $exportParams = @{ } - if ($Format.Count -eq 1 -and $Format -eq 'HTML') { - $exportParams += @{ - Options = @{ NoPageLayoutStyle = $true } - } - } - - Document $BaseFileName { - - # Global options - GlobalOption -PageSize A4 - - - #Variables used to create numbers for TOC and subsections - $Head1Counter = 1 - - If (-not $SkipTableOfContent.ispresent) { - - # Table of content - [String]$TOCName = $LocalizedStrings.msg01 - - TOC -Name $TOCName - - } - - If (-not $SkipSummary.IsPresent) { - - # Columns used for the summary table - - #This variable can't be translated - $SummaryColumnsData = @('TotalCount', 'PassedCount', 'FailedCount', 'SkippedCount', 'PendingCount') - - $SummaryColumnsHeaders = @($LocalizedStrings.msg02, $LocalizedStrings.msg03, $LocalizedStrings.msg04, $LocalizedStrings.msg05, $LocalizedStrings.msg06) - - # Style definitions used for the summary table - Style -Name Total -Color White -BackgroundColor Blue - Style -Name Passed -Color White -BackgroundColor Green - Style -Name Failed -Color White -BackgroundColor Red - Style -Name Other -Color White -BackgroundColor Gray - - # Results Summary - - $ResultsSummaryTitle = "{0}.`t{1}" -f $Head1Counter, $LocalizedStrings.msg07 - - $Head1Counter++ - - $ValidResults = $PesterResult | Where-Object { $null -ne $_.TotalCount } | Sort-Object -Property FailedCount -Descending - Section -Name $ResultsSummaryTitle -Style Heading2 -ScriptBlock { - - $ValidResults | Set-Style -Style 'Total' -Property 'TotalCount' - $ValidResults | Set-Style -Style 'Passed' -Property 'PassedCount' - $ValidResults | Set-Style -Style 'Failed' -Property 'FailedCount' - $ValidResults | Set-Style -Style 'Other' -Property 'SkippedCount' - $ValidResults | Set-Style -Style 'Other' -Property 'PendingCount' - $ValidResults | Table -Columns $SummaryColumnsData -Headers $SummaryColumnsHeaders -Width 90 - - } - - } - - If (-not $SummaryOnly.IsPresent) { - - #Expanding Pester summary to receive all tests results - $PesterTestsResults = $PesterResult | Select-Object -ExpandProperty TestResult - - [Array]$EvaluateResults = $null - - If ((-not $PassedOnly.IsPresent) -and $PesterResult.FailedCount -gt 0) { - - $EvaluateResults += 'Failed' - - } - - If ((-not $FailedOnly.IsPresent) -and $PesterResult.PassedCount -gt 0) { - - $EvaluateResults += 'Passed' - - If ($Order -eq 'PassedFirst') { - - $EvaluateResults = $($EvaluateResults | Sort-Object -Descending) - - } - - } - - foreach ($CurrentResultType in $EvaluateResults) { - - switch ($CurrentResultType) { - - 'Passed' { - - $CurrentResultTypeLocalized = $LocalizedStrings.msg09 - - $Head1SectionTitle = $LocalizedStrings.msg25 - - $Header1TitlePart = $LocalizedStrings.msg10 - - $Header2TitlePart = $LocalizedStrings.msg11 - - $Header3TitlePart = $LocalizedStrings.msg12 - - $VerboseMsgHeader2Part = $LocalizedStrings.msg13 - - $VerboseMsgHeader3Part = $LocalizedStrings.msg14 - - #This variable can't be translated - $TestsResultsColumnsData = @('Describe', 'Context', 'Name') - - $TestsResultsColumnsHeaders = @($LocalizedStrings.msg15, $LocalizedStrings.msg16, $LocalizedStrings.msg17) - - } - - - 'Failed' { - - $CurrentResultTypeLocalized = $LocalizedStrings.msg18 - - $Head1SectionTitle = $LocalizedStrings.msg26 - - $Header1TitlePart = $LocalizedStrings.msg19 - - $Header2TitlePart = $LocalizedStrings.msg20 - - $Header3TitlePart = $LocalizedStrings.msg21 - - $VerboseMsgHeader2Part = $LocalizedStrings.msg22 - - $VerboseMsgHeader3Part = $LocalizedStrings.msg23 - - #This variable can't be translated - $TestsResultsColumnsData = @('Context', 'Name', 'FailureMessage') - - $TestsResultsColumnsHeaders = @($LocalizedStrings.msg16, $LocalizedStrings.msg17, $LocalizedStrings.msg24) - - } - - } - - $VerboseMsgMainLoop = $LocalizedStrings.msg08 - - [String]$MessageText = "{0} {1} " -f $VerboseMsgMainLoop, $CurrentResultTypeLocalized - - Write-Verbose -Message $MessageText - - $Head2counter = 1 - - $Head3counter = 1 - - If (-not $PassedOnly.IsPresent) { - - $CurrentPesterTestResults = $PesterTestsResults | Where-object -FilterScript { $_.Result -eq $CurrentResultType } - - If ($GroupResultsBy -eq 'Result') { - - [String]$Header1Title = "{0}.`t {1}" -f $Head1counter, $Header1TitlePart - - Section -Name $Header1Title -Style Heading1 { - - $CurrentPesterTestResults | - Table -Columns $TestsResultsColumnsData -Headers $TestsResultsColumnsHeaders -Width 90 - - } - - $Head1counter++ - - } - - Else { - - Section -Name "$Head1Counter.`t $Head1SectionTitle " -Style Heading1 -ScriptBlock { - - #Get unique 'Describe' from Pester results - [Array]$Headers2 = $CurrentPesterTestResults | Select-Object -Property Describe -Unique - - # Tests results details - Grouped by Describe - foreach ($Header2 in $Headers2) { - - [String]$MessageText = "{0}: {1} " -f $VerboseMsgHeader2Part, $($Header2.Describe) - - Write-Verbose -Message $MessageText - - $SubHeader2Number = "{0}.{1}" -f $Head1Counter, $Head2counter - - [String]$Header2Title = "{0}.`t {1} {2}" -f $SubHeader2Number, $Header2TitlePart, $($Header2.Describe) - - Section -Name $Header2Title -Style Heading2 -ScriptBlock { - - $CurrentPesterTestResults2 = $CurrentPesterTestResults | Where-Object -FilterScript { $_.Describe -eq $Header2.Describe } - - $CurrentPesterTestResultsCount2 = ($CurrentPesterTestResults2 | Measure-Object).Count - - If ($GroupResultsBy -eq 'Result-Describe-Context') { - - [Array]$Headers3 = $CurrentPesterTestResults2 | Select-Object -Property Context -Unique - - foreach ($Header3 in $Headers3) { - - [String]$MessageText = "{0}: {1} " -f $VerboseMsgHeader3Part, $($Header3.Context) - - Write-Verbose -Message $MessageText - - $CurrentPesterTestResults3 = $CurrentPesterTestResults2 | Where-Object -FilterScript { $_.Context -eq $Header3.Context } - - $CurrentPesterTestResultsCount3 = ($CurrentPesterTestResults3 | Measure-Object).Count - - $SubHeader3Number = "{0}.{1}.{2}" -f $Head1Counter, $Head2counter, $Head3counter - - [String]$Header3Title = "{0}.`t {1} {2}" -f $SubHeader3Number, $Header3TitlePart, $($Header3.Context) - - Section -Name $Header3Title -Style Heading3 -ScriptBlock { - - $MessageText = "{0} {1} {2}, {3} {4}" -f $LocalizedStrings.msg30, $Header3TitlePart, $($Header3.Context), $LocalizedStrings.msg31, $CurrentPesterTestResultsCount3 - - Write-Verbose -Message $MessageText - - $CurrentPesterTestResults3 | - Table -Columns $TestsResultsColumnsData -Headers $TestsResultsColumnsHeaders -Width 90 - } - - $Head3Counter++ - - } - - } #$GroupResultsBy -eq 'Result-Describe-Context' - Else { - - $MessageText = "{0} {1} {2}, {3}: {4}" -f $LocalizedStrings.msg30, $Header3TitlePart, $($Header3.Context), $LocalizedStrings.msg31, $CurrentPesterTestResultsCount3 - - Write-Verbose -Message $MessageText - - $CurrentPesterTestResults2 | - Table -Columns $TestsResultsColumnsData -Headers $TestsResultsColumnsHeaders -Width 90 - - } - - } - - $Head2counter++ - - } #end foreach ($Header2 in $FailedHeaders2) - - } - - $Head1Counter++ - - } #end $GroupResultsBy -ne 'Result' - - } - - } - - } - - } | Export-Document -Path $Path -Format $Format @exportParams -} +Function Format-Pester { +<# + .SYNOPSIS + Document Pester's tests results into the selected format (HTML, Word, Text). + + .DESCRIPTION + Create documents in formats: HTML, Word, Text using PScribo PowerShell module. Documents are preformated to be human friendly. + Local Word installation is not needed to be installed on the computers were documents. + + Additional languages (other than en-US) can be used - please read info for translator on the project web page. + + .PARAMETER PesterResult + Specifies the Pester results Object + + .PARAMETER Format + Specifies the document format. Might be: + - Text + - HTML + - Word + + .PARAMETER Path + Specifies where the documents will be stored. Default is the path where is executed this function. + + .PARAMETER BaseFileName + Specifies the document name. Default is 'Pester_Results'. + + .PARAMETER Order + Specify what results need to be evaluated first - passed or failed - means that will be included on the top of report. + By default failed tests are evaluated first. + + .PARAMETER GroupResultsBy + Select how results should be groupped. Available options: Result, Result-Describe, Result-Describe-Context. + + .PARAMETER PassedOnly + Select to return information about passed tests only. + + .PARAMETER FailedOnly + Select to return information about failed tests only. + + .PARAMETER SummaryOnly + Select to return only summaries for tests only (sums of numbers passed/failed/etc. tests). + + .PARAMETER SkipTableOfContent + Select to skip adding table of content at the begining of document(s). + + .PARAMETER SkipSummary + Select to skip adding table with test summaries (sums of numbers passed/failed/etc. tests). + + .PARAMETER Language + Select language what need to be used for generated reports. + By default language is detected by Get-Culture with fallback to en-US if translation is not available. + + .PARAMETER Version + Use that parameter to display version of Format-Pester only. + This parameter can be used to verify translations. + + .PARAMETER DumpPScriboObject + When DumpPscriboObject is used the result of the function is custom object containing PScribo Document. + Use this parameter for prepare tests or debug of document generation. + + .INPUTS + An expected input is the result of the command Invoke-Pester with the parameter -PassThru. + With that command Invoke-Pester returns a custom object (PSCustomObject) that contains the test results. + + .OUTPUTS + Files what contain results of test. Files format and structure is based on values of parameters used. + + .EXAMPLE + Invoke-Pester -PassThru | Format-Pester -Path . -Format HTML,Word,Text -BaseFileName 'PesterResults' + + This command will document the results of the Pester's tests. + Documents will be stored in the current path and they will be available in 3 formats (.html,.docx and .txt). + + .LINK + https://github.com/equelin/Format-Pester + + .NOTES + Initial author: Erwan Quelin + + Credits/coauthors: + - Travis Plunk, github[at]ez13[dot]net + - Wojciech Sciesinski, wojciech[at]sciesinski[dot]net + + LICENSE + Licensed under the MIT License - https://github.com/equelin/Format-Pester/blob/master/LICENSE + + TODO + - Pester test need to be updated - yes, post factum TDD ;-) + + #> + + [CmdletBinding(DefaultParameterSetName = 'AllParamSet')] + [OutputType([IO.FileInfo])] + Param ( + [Parameter(Mandatory = $true, Position = 0, ValueFromPipeline = $True, ValueFromPipelinebyPropertyName = $True, HelpMessage = 'Pester results Object', ParameterSetName = 'AllParamSet')] + [Parameter(Mandatory = $true, Position = 0, ValueFromPipeline = $True, ValueFromPipelinebyPropertyName = $True, HelpMessage = 'Pester results Object', ParameterSetName = 'PassedOnlyParamSet')] + [Parameter(Mandatory = $true, Position = 0, ValueFromPipeline = $True, ValueFromPipelinebyPropertyName = $True, HelpMessage = 'Pester results Object', ParameterSetName = 'FailedOnlyParamSet')] + [Parameter(Mandatory = $true, Position = 0, ValueFromPipeline = $True, ValueFromPipelinebyPropertyName = $True, HelpMessage = 'Pester results Object', ParameterSetName = 'SummaryOnlyParamSet')] + [Parameter(Mandatory = $false, Position = 0, ValueFromPipeline = $True, ValueFromPipelinebyPropertyName = $True, HelpMessage = 'Pester results Object', ParameterSetName = 'VersionOnlyParamSet')] + [Array]$PesterResult, + [Parameter(Mandatory = $true, HelpMessage = 'PScribo export format', ParameterSetName = 'AllParamSet')] + [Parameter(Mandatory = $true, ParameterSetName = 'PassedOnlyParamSet')] + [Parameter(Mandatory = $true, ParameterSetName = 'FailedOnlyParamSet')] + [Parameter(Mandatory = $true, ParameterSetName = 'SummaryOnlyParamSet')] + [Parameter(Mandatory = $false, ParameterSetName = 'VersionOnlyParamSet')] + [ValidateSet('Text', 'Word', 'HTML')] + [String[]]$Format, + [Parameter(Mandatory = $false, HelpMessage = 'PScribo export path', ParameterSetName = 'AllParamSet')] + [Parameter(Mandatory = $false, ParameterSetName = 'PassedOnlyParamSet')] + [Parameter(Mandatory = $false, ParameterSetName = 'FailedOnlyParamSet')] + [Parameter(Mandatory = $false, ParameterSetName = 'SummaryOnlyParamSet')] + [ValidateNotNullorEmpty()] + [String]$Path = (Get-Location -PSProvider FileSystem), + [ValidateNotNullorEmpty()] + [string]$BaseFileName = 'Pester_Results', + [Parameter(Mandatory = $false, ParameterSetName = 'AllParamSet')] + [ValidateSet('FailedFirst', 'PassedFirst')] + [String]$Order = 'FailedFirst', + [Parameter(Mandatory = $false, ParameterSetName = 'AllParamSet')] + [Parameter(Mandatory = $false, ParameterSetName = 'PassedOnlyParamSet')] + [Parameter(Mandatory = $false, ParameterSetName = 'FailedOnlyParamSet')] + [ValidateSet('Result', 'Result-Describe', 'Result-Describe-Context')] + [String]$GroupResultsBy = 'Result', + [Parameter(Mandatory = $false, ParameterSetName = 'PassedOnlyParamSet')] + [Switch]$PassedOnly, + [Parameter(Mandatory = $false, ParameterSetName = 'FailedOnlyParamSet')] + [Switch]$FailedOnly, + [Parameter(Mandatory = $false, ParameterSetName = 'SummaryOnlyParamSet')] + [switch]$SummaryOnly, + [Parameter(Mandatory = $false, ParameterSetName = 'AllParamSet')] + [Parameter(Mandatory = $false, ParameterSetName = 'PassedOnlyParamSet')] + [Parameter(Mandatory = $false, ParameterSetName = 'FailedOnlyParamSet')] + [Parameter(Mandatory = $false, ParameterSetName = 'SummaryOnlyParamSet')] + [Switch]$SkipTableOfContent, + [Parameter(Mandatory = $false, ParameterSetName = 'AllParamSet')] + [Parameter(Mandatory = $false, ParameterSetName = 'PassedOnlyParamSet')] + [Parameter(Mandatory = $false, ParameterSetName = 'FailedOnlyParamSet')] + [Switch]$SkipSummary, + [Parameter(Mandatory = $false, ParameterSetName = 'AllParamSet')] + [Parameter(Mandatory = $false, ParameterSetName = 'PassedOnlyParamSet')] + [Parameter(Mandatory = $false, ParameterSetName = 'FailedOnlyParamSet')] + [Parameter(Mandatory = $false, ParameterSetName = 'SummaryOnlyParamSet')] + [String]$Language = $($(Get-Culture).Name), + [Parameter(Mandatory = $false, ParameterSetName = 'VersionOnlyParamSet')] + [Switch]$Version, + [Parameter(Mandatory = $false, ParameterSetName = 'AllParamSet')] + [Parameter(Mandatory = $false, ParameterSetName = 'PassedOnlyParamSet')] + [Parameter(Mandatory = $false, ParameterSetName = 'FailedOnlyParamSet')] + [Parameter(Mandatory = $false, ParameterSetName = 'SummaryOnlyParamSet')] + [Switch]$DumpPScriboObject + ) + + [Version]$ScriptVersion = "1.4.0" + + If ($Version.IsPresent) { + + Return $ScriptVersion.ToString() + + Break + + } + Else { + + if ($null -eq $PesterResult) { + + $MessageText = "Value of the parameter PesterResult can't be null or empty." + + Throw $MessageText + + } + + } + + Import-LocalizedData -FileName Format-Pester.psd1 -BindingVariable LocalizedStrings -UICulture $Language -ErrorAction SilentlyContinue + + If ([String]::IsNullOrEmpty($LocalizedStrings)) { + + Import-LocalizedData -FileName Format-Pester.psd1 -BindingVariable LocalizedStrings -UICulture 'en-US' -ErrorAction Stop + + [String]$MessageText = "{0} {1} {2}" -f $LocalizedStrings.msg27, $Language, $LocalizedStrings.msg28 + + Write-Verbose -Message $MessageText + + } + + If ($LocalizedStrings.msg00 -lt $ScriptVersion) { + + [String]$MessageText = "{0}" -f $LocalizedStrings.msg29 + + Write-Warning -Message $MessageText + + } + + $TextFileEncoding = $LocalizedStrings.msg32 + + #LocalizedStrings are not sorted alphabeticaly -even if you are using Sort-Object ! + #$LocalizedStrings + + $exportParams = @{ } + if ($Format.Count -eq 1 -and $Format -eq 'HTML') { + + $exportParams += @{ + + Options = @{ NoPageLayoutStyle = $true } + } + + + } + elseif ($Format -contains 'text' -and $TextFileEncoding -ne 'ASCII') { + + $exportParams += @{ + + Options = @{ Encoding = $TextFileEncoding } + + } + + + } + + + $PScriboObject = Document $BaseFileName { + + # Global options + GlobalOption -PageSize A4 + + + #Variables used to create numbers for TOC and subsections + $Head1Counter = 1 + + If (-not $SkipTableOfContent.ispresent) { + + # Table of content header text + [String]$TOCName = $LocalizedStrings.msg01 + + TOC -Name $TOCName + + } + + If (-not $SkipSummary.IsPresent) { + + # Columns used for the summary table + + #This variable can't be translated + $SummaryColumnsData = @('TotalCount', 'PassedCount', 'FailedCount', 'SkippedCount', 'PendingCount') + + $SummaryColumnsHeaders = @($LocalizedStrings.msg02, $LocalizedStrings.msg03, $LocalizedStrings.msg04, $LocalizedStrings.msg05, $LocalizedStrings.msg06) + + # Style definitions used for the summary table + Style -Name Total -Color White -BackgroundColor Blue + Style -Name Passed -Color White -BackgroundColor Green + Style -Name Failed -Color White -BackgroundColor Red + Style -Name Other -Color White -BackgroundColor Gray + + # Results Summary + + $ResultsSummaryTitle = "{0}.`t{1}" -f $Head1Counter, $LocalizedStrings.msg07 + + $Head1Counter++ + + $ValidResults = $PesterResult | Where-Object { $null -ne $_.TotalCount } | Sort-Object -Property FailedCount -Descending + Section -Name $ResultsSummaryTitle -Style Heading2 -ScriptBlock { + + $ValidResults | Set-Style -Style 'Total' -Property 'TotalCount' + $ValidResults | Set-Style -Style 'Passed' -Property 'PassedCount' + $ValidResults | Set-Style -Style 'Failed' -Property 'FailedCount' + $ValidResults | Set-Style -Style 'Other' -Property 'SkippedCount' + $ValidResults | Set-Style -Style 'Other' -Property 'PendingCount' + $ValidResults | Table -Columns $SummaryColumnsData -Headers $SummaryColumnsHeaders -Width 90 + + } + + } + + If (-not $SummaryOnly.IsPresent) { + + #Expanding Pester summary to receive all tests results + $PesterTestsResults = $PesterResult | Select-Object -ExpandProperty TestResult + + [Array]$EvaluateResults = $null + + If ((-not $PassedOnly.IsPresent) -and $PesterResult.FailedCount -gt 0) { + + $EvaluateResults += 'Failed' + + } + + If ((-not $FailedOnly.IsPresent) -and $PesterResult.PassedCount -gt 0) { + + $EvaluateResults += 'Passed' + + If ($Order -eq 'PassedFirst') { + + $EvaluateResults = $($EvaluateResults | Sort-Object -Descending) + + } + + } + + foreach ($CurrentResultType in $EvaluateResults) { + + switch ($CurrentResultType) { + + 'Passed' { + + $CurrentResultTypeLocalized = $LocalizedStrings.msg09 + + $Head1SectionTitle = $LocalizedStrings.msg25 + + $Header1TitlePart = $LocalizedStrings.msg10 + + $Header2TitlePart = $LocalizedStrings.msg11 + + $Header3TitlePart = $LocalizedStrings.msg12 + + $VerboseMsgHeader2Part = $LocalizedStrings.msg13 + + $VerboseMsgHeader3Part = $LocalizedStrings.msg14 + + #This variable can't be translated + $TestsResultsColumnsData = @('Describe', 'Context', 'Name') + + $TestsResultsColumnsHeaders = @($LocalizedStrings.msg15, $LocalizedStrings.msg16, $LocalizedStrings.msg17) + + } + + + 'Failed' { + + $CurrentResultTypeLocalized = $LocalizedStrings.msg18 + + $Head1SectionTitle = $LocalizedStrings.msg26 + + $Header1TitlePart = $LocalizedStrings.msg19 + + $Header2TitlePart = $LocalizedStrings.msg20 + + $Header3TitlePart = $LocalizedStrings.msg21 + + $VerboseMsgHeader2Part = $LocalizedStrings.msg22 + + $VerboseMsgHeader3Part = $LocalizedStrings.msg23 + + #This variable can't be translated + $TestsResultsColumnsData = @('Context', 'Name', 'FailureMessage') + + $TestsResultsColumnsHeaders = @($LocalizedStrings.msg16, $LocalizedStrings.msg17, $LocalizedStrings.msg24) + + } + + } + + $VerboseMsgMainLoop = $LocalizedStrings.msg08 + + [String]$MessageText = "{0} {1} " -f $VerboseMsgMainLoop, $CurrentResultTypeLocalized + + Write-Verbose -Message $MessageText + + $Head2counter = 1 + + $Head3counter = 1 + + If (-not $PassedOnly.IsPresent) { + + $CurrentPesterTestResults = $PesterTestsResults | Where-object -FilterScript { $_.Result -eq $CurrentResultType } + + If ($GroupResultsBy -eq 'Result') { + + [String]$Header1Title = "{0}.`t {1}" -f $Head1counter, $Header1TitlePart + + Section -Name $Header1Title -Style Heading1 { + + $CurrentPesterTestResults | + Table -Columns $TestsResultsColumnsData -Headers $TestsResultsColumnsHeaders -Width 90 + + } + + $Head1counter++ + + } + + Else { + + Section -Name "$Head1Counter.`t $Head1SectionTitle " -Style Heading1 -ScriptBlock { + + #Get unique 'Describe' from Pester results + [Array]$Headers2 = $CurrentPesterTestResults | Select-Object -Property Describe -Unique + + # Tests results details - Grouped by Describe + foreach ($Header2 in $Headers2) { + + [String]$MessageText = "{0}: {1} " -f $VerboseMsgHeader2Part, $($Header2.Describe) + + Write-Verbose -Message $MessageText + + $SubHeader2Number = "{0}.{1}" -f $Head1Counter, $Head2counter + + [String]$Header2Title = "{0}.`t {1} {2}" -f $SubHeader2Number, $Header2TitlePart, $($Header2.Describe) + + Section -Name $Header2Title -Style Heading2 -ScriptBlock { + + $CurrentPesterTestResults2 = $CurrentPesterTestResults | Where-Object -FilterScript { $_.Describe -eq $Header2.Describe } + + $CurrentPesterTestResultsCount2 = ($CurrentPesterTestResults2 | Measure-Object).Count + + If ($GroupResultsBy -eq 'Result-Describe-Context') { + + [Array]$Headers3 = $CurrentPesterTestResults2 | Select-Object -Property Context -Unique + + foreach ($Header3 in $Headers3) { + + [String]$MessageText = "{0}: {1} " -f $VerboseMsgHeader3Part, $($Header3.Context) + + Write-Verbose -Message $MessageText + + $CurrentPesterTestResults3 = $CurrentPesterTestResults2 | Where-Object -FilterScript { $_.Context -eq $Header3.Context } + + $CurrentPesterTestResultsCount3 = ($CurrentPesterTestResults3 | Measure-Object).Count + + $SubHeader3Number = "{0}.{1}.{2}" -f $Head1Counter, $Head2counter, $Head3counter + + [String]$Header3Title = "{0}.`t {1} {2}" -f $SubHeader3Number, $Header3TitlePart, $($Header3.Context) + + Section -Name $Header3Title -Style Heading3 -ScriptBlock { + + $MessageText = "{0} {1} {2}, {3} {4}" -f $LocalizedStrings.msg30, $Header3TitlePart, $($Header3.Context), $LocalizedStrings.msg31, $CurrentPesterTestResultsCount3 + + Write-Verbose -Message $MessageText + + $CurrentPesterTestResults3 | + Table -Columns $TestsResultsColumnsData -Headers $TestsResultsColumnsHeaders -Width 90 + } + + $Head3Counter++ + + } + + } #$GroupResultsBy -eq 'Result-Describe-Context' + Else { + + $MessageText = "{0} {1} {2}, {3}: {4}" -f $LocalizedStrings.msg30, $Header3TitlePart, $($Header3.Context), $LocalizedStrings.msg31, $CurrentPesterTestResultsCount3 + + Write-Verbose -Message $MessageText + + $CurrentPesterTestResults2 | + Table -Columns $TestsResultsColumnsData -Headers $TestsResultsColumnsHeaders -Width 90 + + } + + } + + $Head2counter++ + + } #end foreach ($Header2 in $Headers2) + + } + + $Head1Counter++ + + } #end $GroupResultsBy -ne 'Result' + + } + + } + + } + + } + + If ($DumpPScriboObject.IsPresent) { + + Return $PScriboObject + + } + + $PScriboObject | Export-Document -Path $Path -Format $Format @exportParams + +} diff --git a/Format-Pester/Public/en-US/Format-Pester.psd1 b/Format-Pester/Public/en-US/Format-Pester.psd1 index ba6e985..25702bd 100644 --- a/Format-Pester/Public/en-US/Format-Pester.psd1 +++ b/Format-Pester/Public/en-US/Format-Pester.psd1 @@ -1,43 +1,46 @@ -#Please read the section 'Information for translators' on the GitHub project page -#Read also Get-Help about_Script_Internationalization - -#The language en-US file prepared by Wojciech Sciesinski, wojciech[at]sciesinski[dot]net -#String aligned to version - see msg00 value - -#Translate values, don't touch 'msgxx' fields ! - -# culture="en-US" -ConvertFrom-StringData @' - msg00 = 1.3.3 - msg01 = Table of Contents - msg02 = Total Tests - msg03 = Passed Tests - msg04 = Failed Tests - msg05 = Skipped Tests - msg06 = Pending Tests - msg07 = Results summary - msg08 = Evaluating tests results for - msg09 = Passed - msg10 = Details for passed tests - msg11 = Details for passed tests by Describe block: - msg12 = Details for passed tests by Context block: - msg13 = Found passed tests in Decribe blocks - msg14 = Found passed tests in Context block - msg15 = Describe - msg16 = Context - msg17 = Name - msg18 = Failed - msg19 = Details for failed tests - msg20 = Details for failed tests by Describe block: - msg21 = Details for failed tests by Context block: - msg22 = Found failed tests in Decribe blocks - msg23 = Found failed in Context blocks - msg24 = Failure Message - msg25 = Passed tests - msg26 = Failed tests - msg27 = The language - msg28 = is not supported. Language en-US will be used. - msg29 = Version of used language file is diffrent than than version of Format-Pester.ps1 file. Some texts can not be displayed correctly. - msg30 = Performing action for - msg31 = amount of results +#Please read the section 'Information for translators' on the GitHub project page +#Read also Get-Help about_Script_Internationalization + +#The language en-US file prepared by Wojciech Sciesinski, wojciech[at]sciesinski[dot]net +#String aligned to version - see msg00 value + +#Translate values, don't touch 'msgxx' fields ! + +# culture="en-US" +ConvertFrom-StringData @' + msg00 = 1.4.0 + msg01 = Table of Contents + msg02 = Total Tests + msg03 = Passed Tests + msg04 = Failed Tests + msg05 = Skipped Tests + msg06 = Pending Tests + msg07 = Results summary + msg08 = Evaluating tests results for + msg09 = Passed + msg10 = Details for passed tests + msg11 = Details for passed tests by Describe block: + msg12 = Details for passed tests by Context block: + msg13 = Found passed tests in Decribe blocks + msg14 = Found passed tests in Context block + msg15 = Describe + msg16 = Context + msg17 = Name + msg18 = Failed + msg19 = Details for failed tests + msg20 = Details for failed tests by Describe block: + msg21 = Details for failed tests by Context block: + msg22 = Found failed tests in Decribe blocks + msg23 = Found failed in Context blocks + msg24 = Failure Message + msg25 = Passed tests + msg26 = Failed tests + msg27 = The language + msg28 = is not supported. Language en-US will be used. + msg29 = Version of used language file is diffrent than than version of Format-Pester.ps1 file. Some texts can not be displayed correctly. + msg30 = Performing action for + msg31 = amount of results + #Type of encoding used for write text files + #Supported vales: ASCII,Unicode,UTF7,UTF8 + msg32 = ASCII '@ \ No newline at end of file diff --git a/Format-Pester/Public/pl-PL/Format-Pester.psd1 b/Format-Pester/Public/pl-PL/Format-Pester.psd1 index 1da2528..1799ca6 100644 --- a/Format-Pester/Public/pl-PL/Format-Pester.psd1 +++ b/Format-Pester/Public/pl-PL/Format-Pester.psd1 @@ -1,43 +1,46 @@ -#Please read the section 'Information for translators' on the GitHub project page -#Read also Get-Help about_Script_Internationalization - -#The language pl-PL file prepared by Wojciech Sciesinski, wojciech[at]sciesinski[dot]net -#String aligned to version - see msg00 value - -#Translate values, don't touch 'msgxx' fields ! - -# culture="pl-PL" -ConvertFrom-StringData @' - msg00 = 1.3.3 - msg01 = Spis treści - msg02 = Testy ogółem - msg03 = Testy zdane - msg04 = Testy niezdane - msg05 = Testy pominięte - msg06 = Testy trwające - msg07 = Podsumowanie testów - msg08 = Przetwarzanie rezultatów testów dla - msg09 = Zdane - msg10 = Szczegóły zdanych testów - msg11 = Szczegóły zdanych testów dla bloku Describe: - msg12 = Szczegóły zdanych testów dla bloku Context: - msg13 = Znaleziono zdane testy dla bloku Decribe - msg14 = Znaleziono zdane testy dla bloku Context - msg15 = Describe - msg16 = Context - msg17 = Nazwa - msg18 = Niezdane - msg19 = Szczegóły niezdanych testów - msg20 = Szczegóły niezdanych testów dla bloku Describe: - msg21 = Szczegóły niezdanych testów dla bloku Context: - msg22 = Znaleziono zdane testy dla bloku Decribe - msg23 = Znaleziono zdane testy dla bloku Context - msg24 = Komunikat niezdanego testu - msg25 = Zdane testy - msg26 = Niezdane testy - msg27 = Język - msg28 = nie jest wspierany. Będzie użyty język domyślny tj. en-US. - msg29 = Wersja pliku języka jest inna niż wersja funkcji Format-Pester.ps1. Niektóre teksty mogą być wyświetlane niepoprawnie. - msg30 = Wykonywanie operacji dla - msg31 = liczba rezultatów -'@ \ No newline at end of file +#Please read the section 'Information for translators' on the GitHub project page +#Read also Get-Help about_Script_Internationalization + +#The language pl-PL file prepared by Wojciech Sciesinski, wojciech[at]sciesinski[dot]net +#String aligned to version - see msg00 value + +#Translate values, don't touch 'msgxx' fields ! + +# culture="pl-PL" +ConvertFrom-StringData @' + msg00 = 1.4.0 + msg01 = Spis treści + msg02 = Testy ogółem + msg03 = Testy zdane + msg04 = Testy niezdane + msg05 = Testy pominięte + msg06 = Testy trwające + msg07 = Podsumowanie testów + msg08 = Przetwarzanie rezultatów testów dla + msg09 = Zdane + msg10 = Szczegóły zdanych testów + msg11 = Szczegóły zdanych testów dla bloku Describe: + msg12 = Szczegóły zdanych testów dla bloku Context: + msg13 = Znaleziono zdane testy dla bloku Decribe + msg14 = Znaleziono zdane testy dla bloku Context + msg15 = Describe + msg16 = Context + msg17 = Nazwa + msg18 = Niezdane + msg19 = Szczegóły niezdanych testów + msg20 = Szczegóły niezdanych testów dla bloku Describe: + msg21 = Szczegóły niezdanych testów dla bloku Context: + msg22 = Znaleziono zdane testy dla bloku Decribe + msg23 = Znaleziono zdane testy dla bloku Context + msg24 = Komunikat niezdanego testu + msg25 = Zdane testy + msg26 = Niezdane testy + msg27 = Język + msg28 = nie jest wspierany. Będzie użyty język domyślny tj. en-US. + msg29 = Wersja pliku języka jest inna niż wersja funkcji Format-Pester.ps1. Niektóre teksty mogą być wyświetlane niepoprawnie. + msg30 = Wykonywanie operacji dla + msg31 = liczba rezultatów + #Type of encoding used for write text files + #Supported vales: ASCII,Unicode,UTF7,UTF8 + msg32 = UTF8 +'@ diff --git a/README.md b/README.md index caa625c..26424e9 100644 --- a/README.md +++ b/README.md @@ -1,108 +1,109 @@ -[![Build status](https://ci.appveyor.com/api/projects/status/36q06wp2c4vwfu7w/branch/master?svg=true)](https://ci.appveyor.com/project/equelin/format-pester/branch/master) - -# Format-Pester -Powershell module for documenting Pester's results. - -All the formating work is done by the module [PScribo](https://github.com/iainbrighton/PScribo). - -## Example - -![](./img/format-pester.png) - -Screenshot from HTML report generated by Format-Pester v. 1.3.0, PScribo v. 0.7.11 - -More examples you can find [here](/examples/). - -## Supported languages -Since version 1.3.0 internationalization of generated reports is supported. - -Currently available languages -- en-US - English United Staes - main language -- pl-PL - Polish - -If would you like add support for your language please read the section 'Information for translators' - -# Requirements - -- Powershell v.4.x -- [Pester](https://github.com/pester/Pester) -- [PScribo](https://github.com/iainbrighton/PScribo) - preferred the version >= 0.7.12.47 due to [bug](https://github.com/iainbrighton/PScribo/issues/20) - -# Instructions -## Install the module -```powershell -# One time setup with Powershell 5 - Install-Module Format-Pester - -# Or Manually - # Download the repository - # Unblock the zip - # Extract the Format-Pester folder to a module path (e.g. $env:USERPROFILE\Documents\WindowsPowerShell\Modules\) - -# Import the module - Import-Module Format-Pester #Alternatively, Import-Module \\Path\To\Format-Pester - -# Get commands in the module - Get-Command -Module Format-Pester - -# Help for commands - Get-Help Format-Pester -Full -``` -## Online help -You can read [online version of help](/doc/Format-Pester.md) - online help generated by [platyPS module](https://github.com/powershell/platyps) - -# Usage - -```PowerShell - Invoke-Pester -PassThru | Format-Pester -Path . -Format HTML,Word,Text -``` - -This command will document the results of the Pester's tests. Documents will be store in the current path and they will be available in 3 formats (.html,.docx and .txt). - -# Available functions - -- [Format-Pester](/doc/Format-Pester.md) - -# Contributors - -- Travis Plunk - [GitHub](https://github.com/TravisEz13) - [Twitter](https://twitter.com/TravisPlunk) -- Wojciech Sciesinski - [GitHub](https://github.com/it-praktyk) - [Twitter](https://twitter.com/ITpraktyk) - -# Author - -**Erwan Quélin** -- -- - -# Information for translators -Format-Pester can be used to prepare reports in languages different than English but a language file for your PSCulture/language need to be available. - -To translate required strings to your language please -- read general information about PowerShell support for internationalization - ``` - Get-Help about_Script_Internationalization - ``` - online version about_Script_Internationalization available [here](https://technet.microsoft.com/en-us/library/hh847854.aspx). -- create subfolder with your language/culture code under Public - e.g. xx-XX -- copy the file [Format-Pester.psd1](/Public/en-US/Format-Pester.psd1) from Public\en-US\ to your xx-XX - please don't translate module manifest - files have the same name! -- translate required strings -- test - please use Pester, to skip non-translation related tests please use the command -``` -Invoke-Pester -Path .\tests\ -Tag Translations -``` -you can also uncomment line in the Format-Pester.ps1 file (remember about re-import module with Force) -``` -#$LocalizedStrings -``` -- use the Language parameter if your PSCulture is different than required language for output -- submit your translation to public repo, pull request are welcomed - -# [Version history](VERSIONS.md) - -# License -Copyright 2016 Erwan Quelin and the community. -Licensed under the MIT License - -# TODO -- updated examples - align them to v. 1.3.0 and PScribo 0.7.12.47 -- update VERSIONS.md +[![Build status](https://ci.appveyor.com/api/projects/status/36q06wp2c4vwfu7w/branch/master?svg=true)](https://ci.appveyor.com/project/equelin/format-pester/branch/master) + +# Format-Pester +Powershell module for documenting Pester's results. + +All the formating work is done by the module [PScribo](https://github.com/iainbrighton/PScribo). + +## Example + +![](./img/format-pester.png) + +Screenshot from HTML report generated by Format-Pester v. 1.3.0, PScribo v. 0.7.11 + +More examples you can find [here](/examples/). + +## Supported languages +Since version 1.3.0 internationalization of generated reports is supported. + +Currently available languages +- en-US - English United Staes - main language +- pl-PL - Polish + +If would you like add support for your language please read the section 'Information for translators' + +# Requirements + +- Powershell v.4.x +- [Pester](https://github.com/pester/Pester) +- [PScribo](https://github.com/iainbrighton/PScribo) - preferred the version >= 0.7.12.47 due to [bug](https://github.com/iainbrighton/PScribo/issues/20) + +# Instructions +## Install the module +```powershell +# One time setup with Powershell 5 + Install-Module Format-Pester + +# Or Manually + # Download the repository + # Unblock the zip + # Extract the Format-Pester folder to a module path (e.g. $env:USERPROFILE\Documents\WindowsPowerShell\Modules\) + +# Import the module + Import-Module Format-Pester #Alternatively, Import-Module \\Path\To\Format-Pester + +# Get commands in the module + Get-Command -Module Format-Pester + +# Help for commands + Get-Help Format-Pester -Full +``` +## Online help +You can read [online version of help](/doc/Format-Pester.md) - online help generated by [platyPS module](https://github.com/powershell/platyps) + +# Usage + +```PowerShell + Invoke-Pester -PassThru | Format-Pester -Path . -Format HTML,Word,Text +``` + +This command will document the results of the Pester's tests. Documents will be store in the current path and they will be available in 3 formats (.html,.docx and .txt). + +# Available functions + +- [Format-Pester](/doc/Format-Pester.md) + +# Contributors + +- Travis Plunk - [GitHub](https://github.com/TravisEz13) - [Twitter](https://twitter.com/TravisPlunk) +- Wojciech Sciesinski - [GitHub](https://github.com/it-praktyk) - [Twitter](https://twitter.com/ITpraktyk) + +# Author + +**Erwan Quélin** +- +- + +# Information for translators +Format-Pester can be used to prepare reports in languages different than English but a language file for your PSCulture/language need to be available. + +To translate required strings to your language please +- read general information about PowerShell support for internationalization + ``` + Get-Help about_Script_Internationalization + ``` + online version about_Script_Internationalization available [here](https://technet.microsoft.com/en-us/library/hh847854.aspx). +- create subfolder with your language/culture code under Public - e.g. xx-XX +- copy the file [Format-Pester.psd1](/Public/en-US/Format-Pester.psd1) from Public\en-US\ to your xx-XX - please don't translate module manifest - files have the same name! +- translate required strings +- test - please use Pester, to skip non-translation related tests please use the command +``` +Invoke-Pester -Path .\tests\ -Tag Translations +``` +you can also uncomment line in the Format-Pester.ps1 file (remember about re-import module with Force) +``` +#$LocalizedStrings +``` +- use the Language parameter if your PSCulture is different than required language for output +- submit your translation to public repo, pull requests are welcomed + +# [Version history](VERSIONS.md) + +# License +Copyright 2016 Erwan Quelin and the community. +Licensed under the MIT License + +# TODO +- updated examples - align them to v. 1.4.0 and PScribo 0.7.12.47 +- update VERSIONS.md +- automate preparing example files \ No newline at end of file diff --git a/VERSIONS.md b/VERSIONS.md index 735065d..afcfb8a 100644 --- a/VERSIONS.md +++ b/VERSIONS.md @@ -1,13 +1,25 @@ -#Format-Pester - history of versions - -- 1.3.0 - 2016-08-14 - - - -- 1.3.1 - 2016-08-14 - - added explicit Throw for null or empty PesterResult parameter - - verbose messages updated - - validateSet for the Format paarmeter added/uncommented - - names in code cleaned - -- 1.3.3 - 2016-08-20 - - Fix issue #14 \ No newline at end of file +#Format-Pester - history of versions + +## 1.0.0 - 2016-06-16 + +## 1.1.0 - 2016-07-04 + +## 1.2.0 - 2016-07-20 + +## 1.3.0 - 2016-08-14 + - + +## 1.3.1 - 2016-08-14 + - Fix: added explicit Throw for null or empty PesterResult parameter + - verbose messages updated + - validateSet for the Format parameter added/uncommented + - names in code cleaned + +## 1.3.3 - 2016-08-20 + - Fix issue #14 + +## 1.4.0 - 2016-09-04 + - Fix issue #12 + - Update + - help: descriptions of INPUTS, OUTPUTS added + - possibility to dump the PScribo Document object added \ No newline at end of file diff --git a/doc/Format-Pester.md b/doc/Format-Pester.md index 1252740..1dd5f41 100644 --- a/doc/Format-Pester.md +++ b/doc/Format-Pester.md @@ -1,315 +1,336 @@ ---- -external help file: Format-Pester-help.xml -online version: https://github.com/equelin/Format-Pester -schema: 2.0.0 ---- - -# Format-Pester -## SYNOPSIS -Document Pester's tests results into the selected format (HTML, Word, Text). - -## SYNTAX - -### AllParamSet (Default) -``` -Format-Pester [-PesterResult] -Format [-Path ] [-BaseFileName ] - [-Order ] [-GroupResultsBy ] [-SkipTableOfContent] [-SkipSummary] [-Language ] -``` - -### VersionOnlyParamSet -``` -Format-Pester [[-PesterResult] ] [-Format ] [-BaseFileName ] [-Version] -``` - -### SummaryOnlyParamSet -``` -Format-Pester [-PesterResult] -Format [-Path ] [-BaseFileName ] - [-SummaryOnly] [-SkipTableOfContent] [-Language ] -``` - -### FailedOnlyParamSet -``` -Format-Pester [-PesterResult] -Format [-Path ] [-BaseFileName ] - [-GroupResultsBy ] [-FailedOnly] [-SkipTableOfContent] [-SkipSummary] [-Language ] -``` - -### PassedOnlyParamSet -``` -Format-Pester [-PesterResult] -Format [-Path ] [-BaseFileName ] - [-GroupResultsBy ] [-PassedOnly] [-SkipTableOfContent] [-SkipSummary] [-Language ] -``` - -## DESCRIPTION -Create documents in formats: HTML, Word, Text using PScribo PowerShell module. -Documents are preformated to be human friendly. -Local Word installation is not needed to be installed on the computers were documents. - -Additional languages (other than en-US) can be used - please read info for translator on the project web page. - -## EXAMPLES - -### -------------------------- EXAMPLE 1 -------------------------- -``` -Invoke-Pester -PassThru | Format-Pester -Path . -Format HTML,Word,Text -BaseFileName 'PesterResults' -``` - -This command will document the results of the Pester's tests. -Documents will be stored in the current path and they will be available in 3 formats (.html,.docx and .txt). - -## PARAMETERS - -### -PesterResult -Specifies the Pester results Object - -```yaml -Type: Array -Parameter Sets: AllParamSet, SummaryOnlyParamSet, FailedOnlyParamSet, PassedOnlyParamSet -Aliases: - -Required: True -Position: 1 -Default value: -Accept pipeline input: True (ByPropertyName, ByValue) -Accept wildcard characters: False -``` - -```yaml -Type: Array -Parameter Sets: VersionOnlyParamSet -Aliases: - -Required: False -Position: 1 -Default value: -Accept pipeline input: True (ByPropertyName, ByValue) -Accept wildcard characters: False -``` - -### -Format -Specifies the document format. -Might be: -- Text -- HTML -- Word - -```yaml -Type: String[] -Parameter Sets: AllParamSet, SummaryOnlyParamSet, FailedOnlyParamSet, PassedOnlyParamSet -Aliases: - -Required: True -Position: Named -Default value: -Accept pipeline input: False -Accept wildcard characters: False -``` - -```yaml -Type: String[] -Parameter Sets: VersionOnlyParamSet -Aliases: - -Required: False -Position: Named -Default value: -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -Path -Specifies where the documents will be stored. -Default is the path where is executed this function. - -```yaml -Type: String -Parameter Sets: AllParamSet, SummaryOnlyParamSet, FailedOnlyParamSet, PassedOnlyParamSet -Aliases: - -Required: False -Position: Named -Default value: (Get-Location -PSProvider FileSystem) -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -BaseFileName -Specifies the document name. -Default is 'Pester_Results'. - -```yaml -Type: String -Parameter Sets: (All) -Aliases: - -Required: False -Position: Named -Default value: Pester_Results -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -Order -Specify what results need to be evaluated first - passed or failed - means that will be included on the top of report. -By default failed tests are evaluated first. - -```yaml -Type: String -Parameter Sets: AllParamSet -Aliases: - -Required: False -Position: Named -Default value: FailedFirst -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -GroupResultsBy -Select how results should be groupped. -Available options: Result, Result-Describe, Result-Describe-Context. - -```yaml -Type: String -Parameter Sets: AllParamSet, FailedOnlyParamSet, PassedOnlyParamSet -Aliases: - -Required: False -Position: Named -Default value: Result -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -PassedOnly -Select to return information about passed tests only. - -```yaml -Type: SwitchParameter -Parameter Sets: PassedOnlyParamSet -Aliases: - -Required: False -Position: Named -Default value: False -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -FailedOnly -Select to return information about failed tests only. - -```yaml -Type: SwitchParameter -Parameter Sets: FailedOnlyParamSet -Aliases: - -Required: False -Position: Named -Default value: False -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -SummaryOnly -Select to return only summaries for tests only (sums of numbers passed/failed/etc. -tests). - -```yaml -Type: SwitchParameter -Parameter Sets: SummaryOnlyParamSet -Aliases: - -Required: False -Position: Named -Default value: False -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -SkipTableOfContent -Select to skip adding table of content at the begining of document(s). - -```yaml -Type: SwitchParameter -Parameter Sets: AllParamSet, SummaryOnlyParamSet, FailedOnlyParamSet, PassedOnlyParamSet -Aliases: - -Required: False -Position: Named -Default value: False -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -SkipSummary -Select to skip adding table with test summaries (sums of numbers passed/failed/etc. -tests). - -```yaml -Type: SwitchParameter -Parameter Sets: AllParamSet, FailedOnlyParamSet, PassedOnlyParamSet -Aliases: - -Required: False -Position: Named -Default value: False -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -Language -Select language what need to be used for generated reports. -By default language is detected by Get-Culture with fallback to en-US if translation is not available. - -```yaml -Type: String -Parameter Sets: AllParamSet, SummaryOnlyParamSet, FailedOnlyParamSet, PassedOnlyParamSet -Aliases: - -Required: False -Position: Named -Default value: $($(Get-Culture).Name) -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -Version -Use that parameter to display version of Format-Pester only. -This parameter can be used to verify translations. - -```yaml -Type: SwitchParameter -Parameter Sets: VersionOnlyParamSet -Aliases: - -Required: False -Position: Named -Default value: False -Accept pipeline input: False -Accept wildcard characters: False -``` - -## INPUTS - -## OUTPUTS - -### System.IO.FileInfo - -## NOTES -Initial author: Erwan Quelin - -Credits/coauthors: -- Travis Plunk, github\[at\]ez13\[dot\]net -- Wojciech Sciesinski, wojciech\[at\]sciesinski\[dot\]net - -LICENSE -Licensed under the MIT License - https://github.com/equelin/Format-Pester/blob/master/LICENSE - -TODO -- Pester test need to be updated - yes, post factum TDD ;-) -- INPUTS, OUTPUTS need to be described - -## RELATED LINKS - -[https://github.com/equelin/Format-Pester](https://github.com/equelin/Format-Pester) - +--- +external help file: Format-Pester-help.xml +online version: https://github.com/equelin/Format-Pester +schema: 2.0.0 +--- + +# Format-Pester +## SYNOPSIS +Document Pester's tests results into the selected format (HTML, Word, Text). + +## SYNTAX + +### AllParamSet (Default) +``` +Format-Pester [-PesterResult] -Format [-Path ] [-BaseFileName ] + [-Order ] [-GroupResultsBy ] [-SkipTableOfContent] [-SkipSummary] [-Language ] + [-DumpPScriboObject] +``` + +### VersionOnlyParamSet +``` +Format-Pester [[-PesterResult] ] [-Format ] [-BaseFileName ] [-Version] +``` + +### SummaryOnlyParamSet +``` +Format-Pester [-PesterResult] -Format [-Path ] [-BaseFileName ] + [-SummaryOnly] [-SkipTableOfContent] [-Language ] [-DumpPScriboObject] +``` + +### FailedOnlyParamSet +``` +Format-Pester [-PesterResult] -Format [-Path ] [-BaseFileName ] + [-GroupResultsBy ] [-FailedOnly] [-SkipTableOfContent] [-SkipSummary] [-Language ] + [-DumpPScriboObject] +``` + +### PassedOnlyParamSet +``` +Format-Pester [-PesterResult] -Format [-Path ] [-BaseFileName ] + [-GroupResultsBy ] [-PassedOnly] [-SkipTableOfContent] [-SkipSummary] [-Language ] + [-DumpPScriboObject] +``` + +## DESCRIPTION +Create documents in formats: HTML, Word, Text using PScribo PowerShell module. +Documents are preformated to be human friendly. +Local Word installation is not needed to be installed on the computers were documents. + +Additional languages (other than en-US) can be used - please read info for translator on the project web page. + +## EXAMPLES + +### -------------------------- EXAMPLE 1 -------------------------- +``` +Invoke-Pester -PassThru | Format-Pester -Path . -Format HTML,Word,Text -BaseFileName 'PesterResults' +``` + +This command will document the results of the Pester's tests. +Documents will be stored in the current path and they will be available in 3 formats (.html,.docx and .txt). + +## PARAMETERS + +### -PesterResult +Specifies the Pester results Object + +```yaml +Type: Array +Parameter Sets: AllParamSet, SummaryOnlyParamSet, FailedOnlyParamSet, PassedOnlyParamSet +Aliases: + +Required: True +Position: 1 +Default value: +Accept pipeline input: True (ByPropertyName, ByValue) +Accept wildcard characters: False +``` + +```yaml +Type: Array +Parameter Sets: VersionOnlyParamSet +Aliases: + +Required: False +Position: 1 +Default value: +Accept pipeline input: True (ByPropertyName, ByValue) +Accept wildcard characters: False +``` + +### -Format +Specifies the document format. +Might be: +- Text +- HTML +- Word + +```yaml +Type: String[] +Parameter Sets: AllParamSet, SummaryOnlyParamSet, FailedOnlyParamSet, PassedOnlyParamSet +Aliases: + +Required: True +Position: Named +Default value: +Accept pipeline input: False +Accept wildcard characters: False +``` + +```yaml +Type: String[] +Parameter Sets: VersionOnlyParamSet +Aliases: + +Required: False +Position: Named +Default value: +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Path +Specifies where the documents will be stored. +Default is the path where is executed this function. + +```yaml +Type: String +Parameter Sets: AllParamSet, SummaryOnlyParamSet, FailedOnlyParamSet, PassedOnlyParamSet +Aliases: + +Required: False +Position: Named +Default value: (Get-Location -PSProvider FileSystem) +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -BaseFileName +Specifies the document name. +Default is 'Pester_Results'. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: Pester_Results +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Order +Specify what results need to be evaluated first - passed or failed - means that will be included on the top of report. +By default failed tests are evaluated first. + +```yaml +Type: String +Parameter Sets: AllParamSet +Aliases: + +Required: False +Position: Named +Default value: FailedFirst +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -GroupResultsBy +Select how results should be groupped. +Available options: Result, Result-Describe, Result-Describe-Context. + +```yaml +Type: String +Parameter Sets: AllParamSet, FailedOnlyParamSet, PassedOnlyParamSet +Aliases: + +Required: False +Position: Named +Default value: Result +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -PassedOnly +Select to return information about passed tests only. + +```yaml +Type: SwitchParameter +Parameter Sets: PassedOnlyParamSet +Aliases: + +Required: False +Position: Named +Default value: False +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -FailedOnly +Select to return information about failed tests only. + +```yaml +Type: SwitchParameter +Parameter Sets: FailedOnlyParamSet +Aliases: + +Required: False +Position: Named +Default value: False +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -SummaryOnly +Select to return only summaries for tests only (sums of numbers passed/failed/etc. +tests). + +```yaml +Type: SwitchParameter +Parameter Sets: SummaryOnlyParamSet +Aliases: + +Required: False +Position: Named +Default value: False +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -SkipTableOfContent +Select to skip adding table of content at the begining of document(s). + +```yaml +Type: SwitchParameter +Parameter Sets: AllParamSet, SummaryOnlyParamSet, FailedOnlyParamSet, PassedOnlyParamSet +Aliases: + +Required: False +Position: Named +Default value: False +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -SkipSummary +Select to skip adding table with test summaries (sums of numbers passed/failed/etc. +tests). + +```yaml +Type: SwitchParameter +Parameter Sets: AllParamSet, FailedOnlyParamSet, PassedOnlyParamSet +Aliases: + +Required: False +Position: Named +Default value: False +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Language +Select language what need to be used for generated reports. +By default language is detected by Get-Culture with fallback to en-US if translation is not available. + +```yaml +Type: String +Parameter Sets: AllParamSet, SummaryOnlyParamSet, FailedOnlyParamSet, PassedOnlyParamSet +Aliases: + +Required: False +Position: Named +Default value: $($(Get-Culture).Name) +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Version +Use that parameter to display version of Format-Pester only. +This parameter can be used to verify translations. + +```yaml +Type: SwitchParameter +Parameter Sets: VersionOnlyParamSet +Aliases: + +Required: False +Position: Named +Default value: False +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -DumpPScriboObject +When DumpPscriboObject is used the result of the function is custom object containing PScribo Document. +Use this parameter for prepare tests or debug of document generation. + +```yaml +Type: SwitchParameter +Parameter Sets: AllParamSet, SummaryOnlyParamSet, FailedOnlyParamSet, PassedOnlyParamSet +Aliases: + +Required: False +Position: Named +Default value: False +Accept pipeline input: False +Accept wildcard characters: False +``` + +## INPUTS + +### An expected input is the result of the command Invoke-Pester with the parameter -PassThru. +With that command Invoke-Pester returns a custom object (PSCustomObject) that contains the test results. + +## OUTPUTS + +### Files what contain results of test. Files format and structure is based on values of parameters used. + +## NOTES +Initial author: Erwan Quelin + +Credits/coauthors: +- Travis Plunk, github\[at\]ez13\[dot\]net +- Wojciech Sciesinski, wojciech\[at\]sciesinski\[dot\]net + +LICENSE +Licensed under the MIT License - https://github.com/equelin/Format-Pester/blob/master/LICENSE + +TODO +- Pester test need to be updated - yes, post factum TDD ;-) + +## RELATED LINKS + +[https://github.com/equelin/Format-Pester](https://github.com/equelin/Format-Pester) + diff --git a/examples/1.4.0/README.md b/examples/1.4.0/README.md new file mode 100644 index 0000000..c16aecd --- /dev/null +++ b/examples/1.4.0/README.md @@ -0,0 +1,31 @@ +## Example files generated by +- Format-Pester v. 1.4.0 +- Pester v. 3.4.0 +- PScribo v. 0.7.12.47 + +## Known issues +- nothing :-) + +## en-US + +### 20160822a +```powershell +Invoke-Pester -Path .\demo\ -Quiet -PassThru | Format-Pester -Format word,html,text -Path .\examples\1.4.0\en-US\ -BaseFileName 20160904a -GroupResultsBy Result-Describe -Language en-us +``` + +### 20160823b +```powershell +Invoke-Pester -Path .\demo\ -Quiet -PassThru -Tag Static | format-pester -Format word,html,text -Path .\examples\1.4.0\en-US\ -BaseFileName 20160904b -GroupResultsBy Result-Describe-Context -Language en-us +``` + +## pl-PL + +### 20160822a +```powershell +Invoke-Pester -Path .\demo\ -Quiet -PassThru | Format-Pester -Format word,html,text -Path .\examples\1.4.0\pl-PL\ -BaseFileName 20160904a -GroupResultsBy Result-Describe -Language pl-PL +``` + +### 20160823b +```powershell +Invoke-Pester -Path .\demo\ -Quiet -PassThru -Tag Static | format-pester -Format word,html,text -Path .\examples\1.4.0\pl-PL\ -BaseFileName 20160904b -GroupResultsBy Result-Describe-Context -Language pl-PL +``` \ No newline at end of file diff --git a/examples/1.4.0/en-US/20160904a.docx b/examples/1.4.0/en-US/20160904a.docx new file mode 100644 index 0000000..c9f5612 Binary files /dev/null and b/examples/1.4.0/en-US/20160904a.docx differ diff --git a/examples/1.4.0/en-US/20160904a.html b/examples/1.4.0/en-US/20160904a.html new file mode 100644 index 0000000..5b3c859 --- /dev/null +++ b/examples/1.4.0/en-US/20160904a.html @@ -0,0 +1,91 @@ + + +20160904a + +
+

Table of Contents

+ + + + + + + + + + + +
1. Results summary
2. Failed tests
   2.1. Details for failed tests by Describe block: DemoFunction1 - Random
   2.2. Details for failed tests by Describe block: DemoFunction1 - Static
   2.3. Details for failed tests by Describe block: DemoFunction2 - Random
   2.4. Details for failed tests by Describe block: DemoFunction2 - Static
3. Passed tests
   3.1. Details for passed tests by Describe block: DemoFunction1 - Random
   3.2. Details for passed tests by Describe block: DemoFunction1 - Static
   3.3. Details for passed tests by Describe block: DemoFunction2 - Random
   3.4. Details for passed tests by Describe block: DemoFunction2 - Static
+

1. Results summary

+ +
Total TestsPassed TestsFailed TestsSkipped TestsPending Tests
24131100
+

2. Failed tests

2.1. Details for failed tests by Describe block: DemoFunction1 - Random

+ + + + + +
ContextNameFailure Message
Useless test R-1-1does something useful R-1-1-1Expected: {True} +But was: {0}
Useless test R-1-1does something useful R-1-1-2Expected {9} to be less than {7}
Useless test R-1-1does something useful R-1-1-3Expected {57} to be less than {24}
Useless test R-1-2does something useless R-1-2-1Expected: {30} +But was: {29}
Useless test R-1-2does something useless R-1-2-2Expected {2} to be greater than {30}
+

2.2. Details for failed tests by Describe block: DemoFunction1 - Static

+ + + +
ContextNameFailure Message
Useless test S-1-1does something useful S-1-1-1Expected {5} to be less than {3}
Useless test S-1-2does something useless S-1-2-1Expected: {5} +But was: {6}
Useless test S-1-2does something useful S-1-2-3Expected: value was {2}, but should not have been the same
+

2.3. Details for failed tests by Describe block: DemoFunction2 - Random

+ +
ContextNameFailure Message
Useless test R-2-2does something useless R-2-2-1Expected: {30} +But was: {28}
+

2.4. Details for failed tests by Describe block: DemoFunction2 - Static

+ + +
ContextNameFailure Message
Useless test S-2-1does something useful S-2-1-3Expected: value was {56}, but should not have been the same
Useless test S-2-2does something useless S-2-2-2Expected {2} to be greater than {3}
+

3. Passed tests

3.1. Details for passed tests by Describe block: DemoFunction1 - Random

+ +
DescribeContextName
DemoFunction1 - RandomUseless test R-1-2does something useful R-1-2-3
+

3.2. Details for passed tests by Describe block: DemoFunction1 - Static

+ + + +
DescribeContextName
DemoFunction1 - StaticUseless test S-1-1does something useful S-1-1-2
DemoFunction1 - StaticUseless test S-1-1does something useful S-1-1-3
DemoFunction1 - StaticUseless test S-1-2does something useless S-1-2-2
+

3.3. Details for passed tests by Describe block: DemoFunction2 - Random

+ + + + + +
DescribeContextName
DemoFunction2 - RandomUseless test R-2-1does something useful R-2-1-1
DemoFunction2 - RandomUseless test R-2-1does something useful R-2-2-2
DemoFunction2 - RandomUseless test R-2-1does something useful R-2-1-3
DemoFunction2 - RandomUseless test R-2-2does something useless R-2-2-2
DemoFunction2 - RandomUseless test R-2-2does something useful R-2-2-3
+

3.4. Details for passed tests by Describe block: DemoFunction2 - Static

+ + + + +
DescribeContextName
DemoFunction2 - StaticUseless test S-2-1does something useful S-2-1-1
DemoFunction2 - StaticUseless test S-2-1does something useful S-2-2-2
DemoFunction2 - StaticUseless test S-2-2does something useless S-2-2-1
DemoFunction2 - StaticUseless test S-2-2does something useful S-2-2-3
diff --git a/examples/1.4.0/en-US/20160904a.txt b/examples/1.4.0/en-US/20160904a.txt new file mode 100644 index 0000000..be8c51f --- /dev/null +++ b/examples/1.4.0/en-US/20160904a.txt @@ -0,0 +1,113 @@ +Table of Contents +------------------------------------------------------------------------------------------------------------------------ +1. Results summary +2. Failed tests + 2.1. Details for failed tests by Describe block: DemoFunction1 - Random + 2.2. Details for failed tests by Describe block: DemoFunction1 - Static + 2.3. Details for failed tests by Describe block: DemoFunction2 - Random + 2.4. Details for failed tests by Describe block: DemoFunction2 - Static +3. Passed tests + 3.1. Details for passed tests by Describe block: DemoFunction1 - Random + 3.2. Details for passed tests by Describe block: DemoFunction1 - Static + 3.3. Details for passed tests by Describe block: DemoFunction2 - Random + 3.4. Details for passed tests by Describe block: DemoFunction2 - Static + + +1. Results summary +------------------------------------------------------------------------------------------------------------------------ + +Total Tests Passed Tests Failed Tests Skipped Tests Pending Tests +----------- ------------ ------------ ------------- ------------- + 24 13 11 0 0 + + +2. Failed tests +------------------------------------------------------------------------------------------------------------------------ + +2.1. Details for failed tests by Describe block: DemoFunction1 - Random +------------------------------------------------------------------------------------------------------------------------ + +Context Name Failure Message +------- ---- --------------- +Useless test R-1-1 does something useful R-1-1-1 Expected: {True} + But was: {0} +Useless test R-1-1 does something useful R-1-1-2 Expected {9} to be less than {7} +Useless test R-1-1 does something useful R-1-1-3 Expected {57} to be less than {24} +Useless test R-1-2 does something useless R-1-2-1 Expected: {30} + But was: {29} +Useless test R-1-2 does something useless R-1-2-2 Expected {2} to be greater than {30} + + +2.2. Details for failed tests by Describe block: DemoFunction1 - Static +------------------------------------------------------------------------------------------------------------------------ + +Context Name Failure Message +------- ---- --------------- +Useless test S-1-1 does something useful S-1-1-1 Expected {5} to be less than {3} +Useless test S-1-2 does something useless S-1-2-1 Expected: {5} + But was: {6} +Useless test S-1-2 does something useful S-1-2-3 Expected: value was {2}, but should not have been the same + + +2.3. Details for failed tests by Describe block: DemoFunction2 - Random +------------------------------------------------------------------------------------------------------------------------ + +Context Name Failure Message +------- ---- --------------- +Useless test R-2-2 does something useless R-2-2-1 Expected: {30} + But was: {28} + + +2.4. Details for failed tests by Describe block: DemoFunction2 - Static +------------------------------------------------------------------------------------------------------------------------ + +Context Name Failure Message +------- ---- --------------- +Useless test S-2-1 does something useful S-2-1-3 Expected: value was {56}, but should not have been the same +Useless test S-2-2 does something useless S-2-2-2 Expected {2} to be greater than {3} + + +3. Passed tests +------------------------------------------------------------------------------------------------------------------------ + +3.1. Details for passed tests by Describe block: DemoFunction1 - Random +------------------------------------------------------------------------------------------------------------------------ + +Describe Context Name +-------- ------- ---- +DemoFunction1 - Random Useless test R-1-2 does something useful R-1-2-3 + + +3.2. Details for passed tests by Describe block: DemoFunction1 - Static +------------------------------------------------------------------------------------------------------------------------ + +Describe Context Name +-------- ------- ---- +DemoFunction1 - Static Useless test S-1-1 does something useful S-1-1-2 +DemoFunction1 - Static Useless test S-1-1 does something useful S-1-1-3 +DemoFunction1 - Static Useless test S-1-2 does something useless S-1-2-2 + + +3.3. Details for passed tests by Describe block: DemoFunction2 - Random +------------------------------------------------------------------------------------------------------------------------ + +Describe Context Name +-------- ------- ---- +DemoFunction2 - Random Useless test R-2-1 does something useful R-2-1-1 +DemoFunction2 - Random Useless test R-2-1 does something useful R-2-2-2 +DemoFunction2 - Random Useless test R-2-1 does something useful R-2-1-3 +DemoFunction2 - Random Useless test R-2-2 does something useless R-2-2-2 +DemoFunction2 - Random Useless test R-2-2 does something useful R-2-2-3 + + +3.4. Details for passed tests by Describe block: DemoFunction2 - Static +------------------------------------------------------------------------------------------------------------------------ + +Describe Context Name +-------- ------- ---- +DemoFunction2 - Static Useless test S-2-1 does something useful S-2-1-1 +DemoFunction2 - Static Useless test S-2-1 does something useful S-2-2-2 +DemoFunction2 - Static Useless test S-2-2 does something useless S-2-2-1 +DemoFunction2 - Static Useless test S-2-2 does something useful S-2-2-3 + + diff --git a/examples/1.4.0/en-US/20160904b.docx b/examples/1.4.0/en-US/20160904b.docx new file mode 100644 index 0000000..4a4aa61 Binary files /dev/null and b/examples/1.4.0/en-US/20160904b.docx differ diff --git a/examples/1.4.0/en-US/20160904b.html b/examples/1.4.0/en-US/20160904b.html new file mode 100644 index 0000000..0143fbf --- /dev/null +++ b/examples/1.4.0/en-US/20160904b.html @@ -0,0 +1,80 @@ + + +20160904b + +
+

Table of Contents

+ + + + + + + + + + + + + + + +
1. Results summary
2. Failed tests
   2.1. Details for failed tests by Describe block: DemoFunction1 - Static
      2.1.1. Details for failed tests by Context block: Useless test S-1-1
      2.1.2. Details for failed tests by Context block: Useless test S-1-2
   2.2. Details for failed tests by Describe block: DemoFunction2 - Static
      2.2.1. Details for failed tests by Context block: Useless test S-2-1
      2.2.2. Details for failed tests by Context block: Useless test S-2-2
3. Passed tests
   3.1. Details for passed tests by Describe block: DemoFunction1 - Static
      3.1.1. Details for passed tests by Context block: Useless test S-1-1
      3.1.2. Details for passed tests by Context block: Useless test S-1-2
   3.2. Details for passed tests by Describe block: DemoFunction2 - Static
      3.2.1. Details for passed tests by Context block: Useless test S-2-1
      3.2.2. Details for passed tests by Context block: Useless test S-2-2
+

1. Results summary

+ +
Total TestsPassed TestsFailed TestsSkipped TestsPending Tests
127500
+

2. Failed tests

2.1. Details for failed tests by Describe block: DemoFunction1 - Static

2.1.1. Details for failed tests by Context block: Useless test S-1-1

+ +
ContextNameFailure Message
Useless test S-1-1does something useful S-1-1-1Expected {5} to be less than {3}
+

2.1.2. Details for failed tests by Context block: Useless test S-1-2

+ + +
ContextNameFailure Message
Useless test S-1-2does something useless S-1-2-1Expected: {5} +But was: {6}
Useless test S-1-2does something useful S-1-2-3Expected: value was {2}, but should not have been the same
+

2.2. Details for failed tests by Describe block: DemoFunction2 - Static

2.2.1. Details for failed tests by Context block: Useless test S-2-1

+ +
ContextNameFailure Message
Useless test S-2-1does something useful S-2-1-3Expected: value was {56}, but should not have been the same
+

2.2.2. Details for failed tests by Context block: Useless test S-2-2

+ +
ContextNameFailure Message
Useless test S-2-2does something useless S-2-2-2Expected {2} to be greater than {3}
+

3. Passed tests

3.1. Details for passed tests by Describe block: DemoFunction1 - Static

3.1.1. Details for passed tests by Context block: Useless test S-1-1

+ + +
DescribeContextName
DemoFunction1 - StaticUseless test S-1-1does something useful S-1-1-2
DemoFunction1 - StaticUseless test S-1-1does something useful S-1-1-3
+

3.1.2. Details for passed tests by Context block: Useless test S-1-2

+ +
DescribeContextName
DemoFunction1 - StaticUseless test S-1-2does something useless S-1-2-2
+

3.2. Details for passed tests by Describe block: DemoFunction2 - Static

3.2.1. Details for passed tests by Context block: Useless test S-2-1

+ + +
DescribeContextName
DemoFunction2 - StaticUseless test S-2-1does something useful S-2-1-1
DemoFunction2 - StaticUseless test S-2-1does something useful S-2-2-2
+

3.2.2. Details for passed tests by Context block: Useless test S-2-2

+ + +
DescribeContextName
DemoFunction2 - StaticUseless test S-2-2does something useless S-2-2-1
DemoFunction2 - StaticUseless test S-2-2does something useful S-2-2-3
diff --git a/examples/1.4.0/en-US/20160904b.txt b/examples/1.4.0/en-US/20160904b.txt new file mode 100644 index 0000000..2fe308a --- /dev/null +++ b/examples/1.4.0/en-US/20160904b.txt @@ -0,0 +1,114 @@ +Table of Contents +------------------------------------------------------------------------------------------------------------------------ +1. Results summary +2. Failed tests + 2.1. Details for failed tests by Describe block: DemoFunction1 - Static + 2.1.1. Details for failed tests by Context block: Useless test S-1-1 + 2.1.2. Details for failed tests by Context block: Useless test S-1-2 + 2.2. Details for failed tests by Describe block: DemoFunction2 - Static + 2.2.1. Details for failed tests by Context block: Useless test S-2-1 + 2.2.2. Details for failed tests by Context block: Useless test S-2-2 +3. Passed tests + 3.1. Details for passed tests by Describe block: DemoFunction1 - Static + 3.1.1. Details for passed tests by Context block: Useless test S-1-1 + 3.1.2. Details for passed tests by Context block: Useless test S-1-2 + 3.2. Details for passed tests by Describe block: DemoFunction2 - Static + 3.2.1. Details for passed tests by Context block: Useless test S-2-1 + 3.2.2. Details for passed tests by Context block: Useless test S-2-2 + + +1. Results summary +------------------------------------------------------------------------------------------------------------------------ + +Total Tests Passed Tests Failed Tests Skipped Tests Pending Tests +----------- ------------ ------------ ------------- ------------- + 12 7 5 0 0 + + +2. Failed tests +------------------------------------------------------------------------------------------------------------------------ + +2.1. Details for failed tests by Describe block: DemoFunction1 - Static +------------------------------------------------------------------------------------------------------------------------ + +2.1.1. Details for failed tests by Context block: Useless test S-1-1 +------------------------------------------------------------------------------------------------------------------------ + +Context Name Failure Message +------- ---- --------------- +Useless test S-1-1 does something useful S-1-1-1 Expected {5} to be less than {3} + + +2.1.2. Details for failed tests by Context block: Useless test S-1-2 +------------------------------------------------------------------------------------------------------------------------ + +Context Name Failure Message +------- ---- --------------- +Useless test S-1-2 does something useless S-1-2-1 Expected: {5} + But was: {6} +Useless test S-1-2 does something useful S-1-2-3 Expected: value was {2}, but should not have been the same + + +2.2. Details for failed tests by Describe block: DemoFunction2 - Static +------------------------------------------------------------------------------------------------------------------------ + +2.2.1. Details for failed tests by Context block: Useless test S-2-1 +------------------------------------------------------------------------------------------------------------------------ + +Context Name Failure Message +------- ---- --------------- +Useless test S-2-1 does something useful S-2-1-3 Expected: value was {56}, but should not have been the same + + +2.2.2. Details for failed tests by Context block: Useless test S-2-2 +------------------------------------------------------------------------------------------------------------------------ + +Context Name Failure Message +------- ---- --------------- +Useless test S-2-2 does something useless S-2-2-2 Expected {2} to be greater than {3} + + +3. Passed tests +------------------------------------------------------------------------------------------------------------------------ + +3.1. Details for passed tests by Describe block: DemoFunction1 - Static +------------------------------------------------------------------------------------------------------------------------ + +3.1.1. Details for passed tests by Context block: Useless test S-1-1 +------------------------------------------------------------------------------------------------------------------------ + +Describe Context Name +-------- ------- ---- +DemoFunction1 - Static Useless test S-1-1 does something useful S-1-1-2 +DemoFunction1 - Static Useless test S-1-1 does something useful S-1-1-3 + + +3.1.2. Details for passed tests by Context block: Useless test S-1-2 +------------------------------------------------------------------------------------------------------------------------ + +Describe Context Name +-------- ------- ---- +DemoFunction1 - Static Useless test S-1-2 does something useless S-1-2-2 + + +3.2. Details for passed tests by Describe block: DemoFunction2 - Static +------------------------------------------------------------------------------------------------------------------------ + +3.2.1. Details for passed tests by Context block: Useless test S-2-1 +------------------------------------------------------------------------------------------------------------------------ + +Describe Context Name +-------- ------- ---- +DemoFunction2 - Static Useless test S-2-1 does something useful S-2-1-1 +DemoFunction2 - Static Useless test S-2-1 does something useful S-2-2-2 + + +3.2.2. Details for passed tests by Context block: Useless test S-2-2 +------------------------------------------------------------------------------------------------------------------------ + +Describe Context Name +-------- ------- ---- +DemoFunction2 - Static Useless test S-2-2 does something useless S-2-2-1 +DemoFunction2 - Static Useless test S-2-2 does something useful S-2-2-3 + + diff --git a/examples/1.4.0/pl-PL/20160904a.docx b/examples/1.4.0/pl-PL/20160904a.docx new file mode 100644 index 0000000..85d4cb2 Binary files /dev/null and b/examples/1.4.0/pl-PL/20160904a.docx differ diff --git a/examples/1.4.0/pl-PL/20160904a.html b/examples/1.4.0/pl-PL/20160904a.html new file mode 100644 index 0000000..e7b0023 --- /dev/null +++ b/examples/1.4.0/pl-PL/20160904a.html @@ -0,0 +1,91 @@ + + +20160904a + +
+

Spis treści

+ + + + + + + + + + + +
1. Podsumowanie testów
2. Niezdane testy
   2.1. Szczegóły niezdanych testów dla bloku Describe: DemoFunction1 - Random
   2.2. Szczegóły niezdanych testów dla bloku Describe: DemoFunction1 - Static
   2.3. Szczegóły niezdanych testów dla bloku Describe: DemoFunction2 - Random
   2.4. Szczegóły niezdanych testów dla bloku Describe: DemoFunction2 - Static
3. Zdane testy
   3.1. Szczegóły zdanych testów dla bloku Describe: DemoFunction1 - Random
   3.2. Szczegóły zdanych testów dla bloku Describe: DemoFunction1 - Static
   3.3. Szczegóły zdanych testów dla bloku Describe: DemoFunction2 - Random
   3.4. Szczegóły zdanych testów dla bloku Describe: DemoFunction2 - Static
+

1. Podsumowanie testów

+ +
Testy ogółemTesty zdaneTesty niezdaneTesty pominięteTesty trwające
24131100
+

2. Niezdane testy

2.1. Szczegóły niezdanych testów dla bloku Describe: DemoFunction1 - Random

+ + + +
ContextNazwaKomunikat niezdanego testu
Useless test R-1-1does something useful R-1-1-1Expected: {True} +But was: {0}
Useless test R-1-2does something useless R-1-2-1Expected: {30} +But was: {27}
Useless test R-1-2does something useful R-1-2-3Expected {22} to be less than {19}
+

2.2. Szczegóły niezdanych testów dla bloku Describe: DemoFunction1 - Static

+ + + +
ContextNazwaKomunikat niezdanego testu
Useless test S-1-1does something useful S-1-1-1Expected {5} to be less than {3}
Useless test S-1-2does something useless S-1-2-1Expected: {5} +But was: {6}
Useless test S-1-2does something useful S-1-2-3Expected: value was {2}, but should not have been the same
+

2.3. Szczegóły niezdanych testów dla bloku Describe: DemoFunction2 - Random

+ + + +
ContextNazwaKomunikat niezdanego testu
Useless test R-2-1does something useful R-2-2-2Expected {7} to be less than {7}
Useless test R-2-2does something useless R-2-2-1Expected: {30} +But was: {27}
Useless test R-2-2does something useless R-2-2-2Expected {2} to be greater than {30}
+

2.4. Szczegóły niezdanych testów dla bloku Describe: DemoFunction2 - Static

+ + +
ContextNazwaKomunikat niezdanego testu
Useless test S-2-1does something useful S-2-1-3Expected: value was {56}, but should not have been the same
Useless test S-2-2does something useless S-2-2-2Expected {2} to be greater than {3}
+

3. Zdane testy

3.1. Szczegóły zdanych testów dla bloku Describe: DemoFunction1 - Random

+ + + +
DescribeContextNazwa
DemoFunction1 - RandomUseless test R-1-1does something useful R-1-1-2
DemoFunction1 - RandomUseless test R-1-1does something useful R-1-1-3
DemoFunction1 - RandomUseless test R-1-2does something useless R-1-2-2
+

3.2. Szczegóły zdanych testów dla bloku Describe: DemoFunction1 - Static

+ + + +
DescribeContextNazwa
DemoFunction1 - StaticUseless test S-1-1does something useful S-1-1-2
DemoFunction1 - StaticUseless test S-1-1does something useful S-1-1-3
DemoFunction1 - StaticUseless test S-1-2does something useless S-1-2-2
+

3.3. Szczegóły zdanych testów dla bloku Describe: DemoFunction2 - Random

+ + + +
DescribeContextNazwa
DemoFunction2 - RandomUseless test R-2-1does something useful R-2-1-1
DemoFunction2 - RandomUseless test R-2-1does something useful R-2-1-3
DemoFunction2 - RandomUseless test R-2-2does something useful R-2-2-3
+

3.4. Szczegóły zdanych testów dla bloku Describe: DemoFunction2 - Static

+ + + + +
DescribeContextNazwa
DemoFunction2 - StaticUseless test S-2-1does something useful S-2-1-1
DemoFunction2 - StaticUseless test S-2-1does something useful S-2-2-2
DemoFunction2 - StaticUseless test S-2-2does something useless S-2-2-1
DemoFunction2 - StaticUseless test S-2-2does something useful S-2-2-3
diff --git a/examples/1.4.0/pl-PL/20160904a.txt b/examples/1.4.0/pl-PL/20160904a.txt new file mode 100644 index 0000000..90b9cd4 --- /dev/null +++ b/examples/1.4.0/pl-PL/20160904a.txt @@ -0,0 +1,113 @@ +Spis treści +------------------------------------------------------------------------------------------------------------------------ +1. Podsumowanie testów +2. Niezdane testy + 2.1. Szczegóły niezdanych testów dla bloku Describe: DemoFunction1 - Random + 2.2. Szczegóły niezdanych testów dla bloku Describe: DemoFunction1 - Static + 2.3. Szczegóły niezdanych testów dla bloku Describe: DemoFunction2 - Random + 2.4. Szczegóły niezdanych testów dla bloku Describe: DemoFunction2 - Static +3. Zdane testy + 3.1. Szczegóły zdanych testów dla bloku Describe: DemoFunction1 - Random + 3.2. Szczegóły zdanych testów dla bloku Describe: DemoFunction1 - Static + 3.3. Szczegóły zdanych testów dla bloku Describe: DemoFunction2 - Random + 3.4. Szczegóły zdanych testów dla bloku Describe: DemoFunction2 - Static + + +1. Podsumowanie testów +------------------------------------------------------------------------------------------------------------------------ + +Testy ogółem Testy zdane Testy niezdane Testy pominięte Testy trwające +------------ ----------- -------------- --------------- -------------- + 24 13 11 0 0 + + +2. Niezdane testy +------------------------------------------------------------------------------------------------------------------------ + +2.1. Szczegóły niezdanych testów dla bloku Describe: DemoFunction1 - Random +------------------------------------------------------------------------------------------------------------------------ + +Context Nazwa Komunikat niezdanego testu +------- ----- -------------------------- +Useless test R-1-1 does something useful R-1-1-1 Expected: {True} + But was: {0} +Useless test R-1-2 does something useless R-1-2-1 Expected: {30} + But was: {27} +Useless test R-1-2 does something useful R-1-2-3 Expected {22} to be less than {19} + + +2.2. Szczegóły niezdanych testów dla bloku Describe: DemoFunction1 - Static +------------------------------------------------------------------------------------------------------------------------ + +Context Nazwa Komunikat niezdanego testu +------- ----- -------------------------- +Useless test S-1-1 does something useful S-1-1-1 Expected {5} to be less than {3} +Useless test S-1-2 does something useless S-1-2-1 Expected: {5} + But was: {6} +Useless test S-1-2 does something useful S-1-2-3 Expected: value was {2}, but should not have been the same + + +2.3. Szczegóły niezdanych testów dla bloku Describe: DemoFunction2 - Random +------------------------------------------------------------------------------------------------------------------------ + +Context Nazwa Komunikat niezdanego testu +------- ----- -------------------------- +Useless test R-2-1 does something useful R-2-2-2 Expected {7} to be less than {7} +Useless test R-2-2 does something useless R-2-2-1 Expected: {30} + But was: {27} +Useless test R-2-2 does something useless R-2-2-2 Expected {2} to be greater than {30} + + +2.4. Szczegóły niezdanych testów dla bloku Describe: DemoFunction2 - Static +------------------------------------------------------------------------------------------------------------------------ + +Context Nazwa Komunikat niezdanego testu +------- ----- -------------------------- +Useless test S-2-1 does something useful S-2-1-3 Expected: value was {56}, but should not have been the same +Useless test S-2-2 does something useless S-2-2-2 Expected {2} to be greater than {3} + + +3. Zdane testy +------------------------------------------------------------------------------------------------------------------------ + +3.1. Szczegóły zdanych testów dla bloku Describe: DemoFunction1 - Random +------------------------------------------------------------------------------------------------------------------------ + +Describe Context Nazwa +-------- ------- ----- +DemoFunction1 - Random Useless test R-1-1 does something useful R-1-1-2 +DemoFunction1 - Random Useless test R-1-1 does something useful R-1-1-3 +DemoFunction1 - Random Useless test R-1-2 does something useless R-1-2-2 + + +3.2. Szczegóły zdanych testów dla bloku Describe: DemoFunction1 - Static +------------------------------------------------------------------------------------------------------------------------ + +Describe Context Nazwa +-------- ------- ----- +DemoFunction1 - Static Useless test S-1-1 does something useful S-1-1-2 +DemoFunction1 - Static Useless test S-1-1 does something useful S-1-1-3 +DemoFunction1 - Static Useless test S-1-2 does something useless S-1-2-2 + + +3.3. Szczegóły zdanych testów dla bloku Describe: DemoFunction2 - Random +------------------------------------------------------------------------------------------------------------------------ + +Describe Context Nazwa +-------- ------- ----- +DemoFunction2 - Random Useless test R-2-1 does something useful R-2-1-1 +DemoFunction2 - Random Useless test R-2-1 does something useful R-2-1-3 +DemoFunction2 - Random Useless test R-2-2 does something useful R-2-2-3 + + +3.4. Szczegóły zdanych testów dla bloku Describe: DemoFunction2 - Static +------------------------------------------------------------------------------------------------------------------------ + +Describe Context Nazwa +-------- ------- ----- +DemoFunction2 - Static Useless test S-2-1 does something useful S-2-1-1 +DemoFunction2 - Static Useless test S-2-1 does something useful S-2-2-2 +DemoFunction2 - Static Useless test S-2-2 does something useless S-2-2-1 +DemoFunction2 - Static Useless test S-2-2 does something useful S-2-2-3 + + diff --git a/examples/1.4.0/pl-PL/20160904b.docx b/examples/1.4.0/pl-PL/20160904b.docx new file mode 100644 index 0000000..0b0e3cc Binary files /dev/null and b/examples/1.4.0/pl-PL/20160904b.docx differ diff --git a/examples/1.4.0/pl-PL/20160904b.html b/examples/1.4.0/pl-PL/20160904b.html new file mode 100644 index 0000000..dbea587 --- /dev/null +++ b/examples/1.4.0/pl-PL/20160904b.html @@ -0,0 +1,80 @@ + + +20160904b + +
+

Spis treści

+ + + + + + + + + + + + + + + +
1. Podsumowanie testów
2. Niezdane testy
   2.1. Szczegóły niezdanych testów dla bloku Describe: DemoFunction1 - Static
      2.1.1. Szczegóły niezdanych testów dla bloku Context: Useless test S-1-1
      2.1.2. Szczegóły niezdanych testów dla bloku Context: Useless test S-1-2
   2.2. Szczegóły niezdanych testów dla bloku Describe: DemoFunction2 - Static
      2.2.1. Szczegóły niezdanych testów dla bloku Context: Useless test S-2-1
      2.2.2. Szczegóły niezdanych testów dla bloku Context: Useless test S-2-2
3. Zdane testy
   3.1. Szczegóły zdanych testów dla bloku Describe: DemoFunction1 - Static
      3.1.1. Szczegóły zdanych testów dla bloku Context: Useless test S-1-1
      3.1.2. Szczegóły zdanych testów dla bloku Context: Useless test S-1-2
   3.2. Szczegóły zdanych testów dla bloku Describe: DemoFunction2 - Static
      3.2.1. Szczegóły zdanych testów dla bloku Context: Useless test S-2-1
      3.2.2. Szczegóły zdanych testów dla bloku Context: Useless test S-2-2
+

1. Podsumowanie testów

+ +
Testy ogółemTesty zdaneTesty niezdaneTesty pominięteTesty trwające
127500
+

2. Niezdane testy

2.1. Szczegóły niezdanych testów dla bloku Describe: DemoFunction1 - Static

2.1.1. Szczegóły niezdanych testów dla bloku Context: Useless test S-1-1

+ +
ContextNazwaKomunikat niezdanego testu
Useless test S-1-1does something useful S-1-1-1Expected {5} to be less than {3}
+

2.1.2. Szczegóły niezdanych testów dla bloku Context: Useless test S-1-2

+ + +
ContextNazwaKomunikat niezdanego testu
Useless test S-1-2does something useless S-1-2-1Expected: {5} +But was: {6}
Useless test S-1-2does something useful S-1-2-3Expected: value was {2}, but should not have been the same
+

2.2. Szczegóły niezdanych testów dla bloku Describe: DemoFunction2 - Static

2.2.1. Szczegóły niezdanych testów dla bloku Context: Useless test S-2-1

+ +
ContextNazwaKomunikat niezdanego testu
Useless test S-2-1does something useful S-2-1-3Expected: value was {56}, but should not have been the same
+

2.2.2. Szczegóły niezdanych testów dla bloku Context: Useless test S-2-2

+ +
ContextNazwaKomunikat niezdanego testu
Useless test S-2-2does something useless S-2-2-2Expected {2} to be greater than {3}
+

3. Zdane testy

3.1. Szczegóły zdanych testów dla bloku Describe: DemoFunction1 - Static

3.1.1. Szczegóły zdanych testów dla bloku Context: Useless test S-1-1

+ + +
DescribeContextNazwa
DemoFunction1 - StaticUseless test S-1-1does something useful S-1-1-2
DemoFunction1 - StaticUseless test S-1-1does something useful S-1-1-3
+

3.1.2. Szczegóły zdanych testów dla bloku Context: Useless test S-1-2

+ +
DescribeContextNazwa
DemoFunction1 - StaticUseless test S-1-2does something useless S-1-2-2
+

3.2. Szczegóły zdanych testów dla bloku Describe: DemoFunction2 - Static

3.2.1. Szczegóły zdanych testów dla bloku Context: Useless test S-2-1

+ + +
DescribeContextNazwa
DemoFunction2 - StaticUseless test S-2-1does something useful S-2-1-1
DemoFunction2 - StaticUseless test S-2-1does something useful S-2-2-2
+

3.2.2. Szczegóły zdanych testów dla bloku Context: Useless test S-2-2

+ + +
DescribeContextNazwa
DemoFunction2 - StaticUseless test S-2-2does something useless S-2-2-1
DemoFunction2 - StaticUseless test S-2-2does something useful S-2-2-3
diff --git a/examples/1.4.0/pl-PL/20160904b.txt b/examples/1.4.0/pl-PL/20160904b.txt new file mode 100644 index 0000000..6315363 --- /dev/null +++ b/examples/1.4.0/pl-PL/20160904b.txt @@ -0,0 +1,114 @@ +Spis treści +------------------------------------------------------------------------------------------------------------------------ +1. Podsumowanie testów +2. Niezdane testy + 2.1. Szczegóły niezdanych testów dla bloku Describe: DemoFunction1 - Static + 2.1.1. Szczegóły niezdanych testów dla bloku Context: Useless test S-1-1 + 2.1.2. Szczegóły niezdanych testów dla bloku Context: Useless test S-1-2 + 2.2. Szczegóły niezdanych testów dla bloku Describe: DemoFunction2 - Static + 2.2.1. Szczegóły niezdanych testów dla bloku Context: Useless test S-2-1 + 2.2.2. Szczegóły niezdanych testów dla bloku Context: Useless test S-2-2 +3. Zdane testy + 3.1. Szczegóły zdanych testów dla bloku Describe: DemoFunction1 - Static + 3.1.1. Szczegóły zdanych testów dla bloku Context: Useless test S-1-1 + 3.1.2. Szczegóły zdanych testów dla bloku Context: Useless test S-1-2 + 3.2. Szczegóły zdanych testów dla bloku Describe: DemoFunction2 - Static + 3.2.1. Szczegóły zdanych testów dla bloku Context: Useless test S-2-1 + 3.2.2. Szczegóły zdanych testów dla bloku Context: Useless test S-2-2 + + +1. Podsumowanie testów +------------------------------------------------------------------------------------------------------------------------ + +Testy ogółem Testy zdane Testy niezdane Testy pominięte Testy trwające +------------ ----------- -------------- --------------- -------------- + 12 7 5 0 0 + + +2. Niezdane testy +------------------------------------------------------------------------------------------------------------------------ + +2.1. Szczegóły niezdanych testów dla bloku Describe: DemoFunction1 - Static +------------------------------------------------------------------------------------------------------------------------ + +2.1.1. Szczegóły niezdanych testów dla bloku Context: Useless test S-1-1 +------------------------------------------------------------------------------------------------------------------------ + +Context Nazwa Komunikat niezdanego testu +------- ----- -------------------------- +Useless test S-1-1 does something useful S-1-1-1 Expected {5} to be less than {3} + + +2.1.2. Szczegóły niezdanych testów dla bloku Context: Useless test S-1-2 +------------------------------------------------------------------------------------------------------------------------ + +Context Nazwa Komunikat niezdanego testu +------- ----- -------------------------- +Useless test S-1-2 does something useless S-1-2-1 Expected: {5} + But was: {6} +Useless test S-1-2 does something useful S-1-2-3 Expected: value was {2}, but should not have been the same + + +2.2. Szczegóły niezdanych testów dla bloku Describe: DemoFunction2 - Static +------------------------------------------------------------------------------------------------------------------------ + +2.2.1. Szczegóły niezdanych testów dla bloku Context: Useless test S-2-1 +------------------------------------------------------------------------------------------------------------------------ + +Context Nazwa Komunikat niezdanego testu +------- ----- -------------------------- +Useless test S-2-1 does something useful S-2-1-3 Expected: value was {56}, but should not have been the same + + +2.2.2. Szczegóły niezdanych testów dla bloku Context: Useless test S-2-2 +------------------------------------------------------------------------------------------------------------------------ + +Context Nazwa Komunikat niezdanego testu +------- ----- -------------------------- +Useless test S-2-2 does something useless S-2-2-2 Expected {2} to be greater than {3} + + +3. Zdane testy +------------------------------------------------------------------------------------------------------------------------ + +3.1. Szczegóły zdanych testów dla bloku Describe: DemoFunction1 - Static +------------------------------------------------------------------------------------------------------------------------ + +3.1.1. Szczegóły zdanych testów dla bloku Context: Useless test S-1-1 +------------------------------------------------------------------------------------------------------------------------ + +Describe Context Nazwa +-------- ------- ----- +DemoFunction1 - Static Useless test S-1-1 does something useful S-1-1-2 +DemoFunction1 - Static Useless test S-1-1 does something useful S-1-1-3 + + +3.1.2. Szczegóły zdanych testów dla bloku Context: Useless test S-1-2 +------------------------------------------------------------------------------------------------------------------------ + +Describe Context Nazwa +-------- ------- ----- +DemoFunction1 - Static Useless test S-1-2 does something useless S-1-2-2 + + +3.2. Szczegóły zdanych testów dla bloku Describe: DemoFunction2 - Static +------------------------------------------------------------------------------------------------------------------------ + +3.2.1. Szczegóły zdanych testów dla bloku Context: Useless test S-2-1 +------------------------------------------------------------------------------------------------------------------------ + +Describe Context Nazwa +-------- ------- ----- +DemoFunction2 - Static Useless test S-2-1 does something useful S-2-1-1 +DemoFunction2 - Static Useless test S-2-1 does something useful S-2-2-2 + + +3.2.2. Szczegóły zdanych testów dla bloku Context: Useless test S-2-2 +------------------------------------------------------------------------------------------------------------------------ + +Describe Context Nazwa +-------- ------- ----- +DemoFunction2 - Static Useless test S-2-2 does something useless S-2-2-1 +DemoFunction2 - Static Useless test S-2-2 does something useful S-2-2-3 + + diff --git a/tests/Format-Pester-translations.tests.ps1 b/tests/Format-Pester-translations.tests.ps1 index 67a4e11..0a240cc 100644 --- a/tests/Format-Pester-translations.tests.ps1 +++ b/tests/Format-Pester-translations.tests.ps1 @@ -1,288 +1,289 @@ -<# - .SYNOPSIS - Pester tests to validate translations of PowerShell psd1 files. - - .DESCRIPTION - Pester test to validate completeness, versions and equality of used fields between main language (en-US) and other languages stored in language related subfolders. - - General information about PowerShell support for internationalization, please read Get-Help about_Script_Internationalization. - - The tests created initially for the Format-Pester project - https://github.com/equelin/format-pester - internationalization supported since v. 1.3.0. - - .LINK - https://github.com/equelin/Format-Pester - - .NOTES - AUTHOR: Wojciech Sciesinski, wojciech[at]sciesinski[dot]net - KEYWORDS: PowerShell, Translation, Pester, psd1 - - VERSIONS HISTORY - 0.1.0 - 2016-07-30 - The first version - 0.2.0 - 2016-08-02 - Checking if null/empty strings are used, messages for failed tests improved - 0.3.0 - 2016-08-09 - Names of variables used in code generalized, base names located at the begining of code - - TODO - - improve performance for testing in context "Check translation for $SubfolderInPublicName - detailed fields name comparison" - based on the previously calculated difference - - add support for multi functions modules - - LICENSE - Copyright (c) 2016 Wojciech Sciesinski - This function is licensed under The MIT License (MIT) - Full license text: https://opensource.org/licenses/MIT - -#> - - -$ModuleName = 'Format-Pester' - -$BaseTranslationFileName = 'Format-Pester.psd1' - -New-Variable -Scope Global -Name GlobalModuleName -Value $ModuleName -Force - -New-Variable -Scope Global -Name GlobalBaseTranslationFileName -Value $BaseTranslationFileName -Force - -[scriptblock]$ModuleVersionReturned = { Format-Pester -Version } - -Describe -Name "Unit tests for $GlobalModuleName translations" -Tag 'Translations' { - - BeforeAll { - - Remove-Module -Name $GlobalModuleName -ErrorAction SilentlyContinue - - Import-Module "$PSScriptRoot\..\$GlobalModuleName" -Force -Scope Global -ErrorAction Stop - - } - - AfterAll { - - #Remove previously defined variables scoped as global - - $VariablesToRemove = @('GlobalModuleName', 'GlobalBaseTranslationFileName', 'enUSLocalizedStrings1', 'enUSLocalizedStrings2', 'GlobalenUSLocalizedStrings', 'GlobalenUSLocalizedStringCount', 'GlobalenUSLocalizedStringKeys', ` - 'SkipDueEnUSNotImported', 'GlobalCurrentLanguageLocalizedStringCount', 'GlobalCurrentLanguageLocalizedStringKeys', 'DifferencesInKeys', 'KeysNotEqual') - - ForEach ($VariableToRemove in $VariablesToRemove) { - - Remove-Variable -Scope Global -Name $VariableToRemove -Force -ErrorAction SilentlyContinue - - } - - } - - $Module = $(Get-Module -Name $GlobalModuleName) - - $ModuleVersion = $([Version]$Module.Version).ToString() - - $ModulePath = $([System.IO.FileInfo]$Module.Path).DirectoryName - - Context "Compare versions numbers included in module of $GlobalModuleName module and function" { - - It 'Compare versions numbers between module and function' { - - $ModuleVersion | Should be $(& $ModuleVersionReturned) - - } - - } - - Context 'Check the subfolder en-US - main language' { - - - - $enUSfolderInPublic = Get-Item -Path "$ModulePath\Public\en-US" -ErrorAction SilentlyContinue - - It 'Check if the en-US folder exist' { - { Test-Path -Path $enUSfolderInPublic -PathType Container } | Should be $true - - } - - It "Check if the subfolder en-US contains $GlobalBaseTranslationFileName file " { - { Test-Path -Path "$enUSfolderInPublic\$GlobalBaseTranslationFileName" -PathType Leaf } | Should be $true - - } - - It "Check if $BaseTranslationFileName from en-US folder can be imported" { - { Import-LocalizedData -BaseDirectory $("$ModulePath\Public") -FileName $GlobalBaseTranslationFileName -BindingVariable enUSLocalizedStrings1 -UICulture 'en-US' -ErrorAction SilentlyContinue } | Should Not Throw - - Import-LocalizedData -BaseDirectory $("$ModulePath\Public") -FileName $GlobalBaseTranslationFileName -BindingVariable enUSLocalizedStrings2 -UICulture 'en-US' - - New-Variable -Scope Global -Name GlobalenUSLocalizedStrings -Value $enUSLocalizedStrings2 - - New-Variable -Scope Global -Name GlobalenUSLocalizedStringCount -Value $enUSLocalizedStrings2.Count -Force - - New-Variable -Scope Global -Name GlobalenUSLocalizedStringKeys -Value $enUSLocalizedStrings2.Keys -Force - - $GlobalenUSLocalizedStrings = $GlobalenUSLocalizedStrings.GetEnumerator() | Sort-Object -Property Name - - $GlobalenUSLocalizedStringKeys = $GlobalenUSLocalizedStringKeys | Sort-Object - - } - - It "Check if data from the file $BaseTranslationFileName for en-US was correctly assigned to variable." { - - $GlobalenUSLocalizedStringCount | Should BeGreaterThan 0 - - } - - It "Compare version of en-US translation with version of module" { - - $GlobalenUSLocalizedStrings.msg00 | Should be $ModuleVersion - - } - - #Enumerate hashtable and check if keys has assigned values (translations strings are fullfilled) - $GlobalenUSLocalizedStrings.GetEnumerator() | ForEach-Object -Process { - - $CurrentenUSLocalizedStringValue = $_ - - If ([String]::IsNullOrEmpty($CurrentenUSLocalizedStringValue.Value)) { - - It "Check if value for $($_.Key) for en-US is not null or empty." { - - $CurrentenUSLocalizedStringValue.Value | Should Not BeNullOrEmpty - - } - - } - - } - - } - - $SubfoldersInPublic = Get-ChildItem -Path "$ModulePath\Public\" -Directory - - ForEach ($SubfolerInPublic in $SubfoldersInPublic) { - - $SubfolderInPublicName = $SubfolerInPublic.Name - - If ($SubfolderInPublicName -ne 'en-US') { - - Context "Check translations for subfolder $SubfolderInPublicName" { - - $SubfolderInPublicNamePath = $SubfolderInPublic.FullName - - It "Check subfolder name format for the folder $SubfolderInPublicName" { - - $SubfolderInPublicName.Substring(2, 1) | Should be '-' - - } - - It "Check if the subfolder $SubfolderInPublicName contains $BaseTranslationFileName file " { - { Test-Path -Path "$SubfolderInPublicNamePath\Format-Pester.ps1" -PathType Leaf } | Should be $true - - } - - It "Check if $GlobalBaseTranslationFileName from $SubfolderInPublicName folder can be imported and contains data" { - { Import-LocalizedData -BaseDirectory $("$ModulePath\Public") -FileName $GlobalBaseTranslationFileName -BindingVariable CurrentLanguageLocalizedStrings1 -UICulture $SubfolderInPublicName -ErrorAction SilentlyContinue } | Should Not Throw - - Import-LocalizedData -BaseDirectory $("$ModulePath\Public") -FileName $GlobalBaseTranslationFileName -BindingVariable CurrentLanguageLocalizedStrings2 -UICulture $SubfolderInPublicName -ErrorAction SilentlyContinue - - New-Variable -Scope Global -Name GlobalCurrentLanguageLocalizedStrings -Value $CurrentLanguageLocalizedStrings2 -Force - - New-Variable -Scope Global -Name GlobalCurrentLanguageLocalizedStringCount -Value $CurrentLanguageLocalizedStrings2.Count -Force - - New-Variable -Scope Global -Name GlobalCurrentLanguageLocalizedStringKeys -Value $CurrentLanguageLocalizedStrings2.Keys -Force - - $GlobalCurrentLanguageLocalizedStrings = $GlobalCurrentLanguageLocalizedStrings.GetEnumerator() | Sort-Object -Property Name - - $GlobalCurrentLanguageLocalizedStringKeys = $GlobalCurrentLanguageLocalizedStringKeys | Sort-Object - - } - - It "Check if data from the file $BaseTranslationFileName for $SubfolderInPublicName was correctly assigned to variable." { - - $GlobalCurrentLanguageLocalizedStringCount | Should BeGreaterThan 0 - - } - - It "Compare version of $SubfolderInPublicName translation with version of module" { - - $GlobalCurrentLanguageLocalizedStrings.msg00 | Should be $ModuleVersion - - } - - It "Compare amount of strings for en-US and $SubfolderInPublicName" { - - $GlobalenUSLocalizedStringCount | Should be $GlobalCurrentLanguageLocalizedStringCount - - } - - #Enumerate hashtable and check if keys has assigned values (translations strings are fullfilled) - $GlobalCurrentLanguageLocalizedStrings.GetEnumerator() | ForEach-Object -Process { - - $CurrentCurrentLanguageLocalizedStringValue = $_ - - If ([String]::IsNullOrEmpty($CurrentCurrentLanguageLocalizedStringValue.Value)) { - - It "Check if value for $($_.Key) for en-US is not null or empty." { - - $CurrentCurrentLanguageLocalizedStringValue.Value | Should Not BeNullOrEmpty - - } - - } - - } - - It "Compare if names of localization keys for en-US and $SubfolderInPublicName are equal" { - - $DifferencesInKeys = Compare-Object -ReferenceObject $GlobalenUSLocalizedStringKeys -DifferenceObject $GlobalCurrentLanguageLocalizedStringKeys - - If ($DifferencesInKeys) { - - New-Variable -Name KeysNotEqual -Value $true -Scope Global -Force - - #New-Variable -Name GlobalDifferencesInKeys -Value $DifferencesInKeys -Scope Global -Force - - } - - $KeysNotEqual | Should BeNullOrEmpty - - } - - } - - If ($KeysNotEqual) { - - Context "Check translation for $SubfolderInPublicName - detailed fields name comparison" { - - ForEach ($CurrentenUSLocalizedKey in $GlobalenUSLocalizedStringKeys) { - - if ($GlobalCurrentLanguageLocalizedStringKeys -notcontains $CurrentenUSLocalizedKey) { - - It "The language file $SubfolderInPublicName not contains $CurrentenUSLocalizedKey" { - - $CurrentLanguageContainResult = ($GlobalCurrentLanguageLocalizedStringKeys -contains $CurrentenUSLocalizedKey) - - $CurrentLanguageContainResult | Should be $true - - } - - } - - } - - ForEach ($CurrentenLanguageLocalizedKey in $GlobalCurrentLanguageLocalizedStringKeys) { - - if ($GlobalenUSLocalizedStringKeys -notcontains $CurrentenLanguageLocalizedKey) { - - It "The language file en-US does not contain $CurrentenLanguageLocalizedKey available in $SubfolderInPublicName" { - - $EnUSLanguageContainResult = ($GlobalenUSLocalizedStringKeys -contains $CurrentenLanguageLocalizedKey) - - $EnUSLanguageContainResult | Should be $true - - } - - } - - } - - } - - } - - } - - } - +<# + .SYNOPSIS + Pester tests to validate translations of PowerShell psd1 files. + + .DESCRIPTION + Pester test to validate completeness, versions and equality of used fields between main language (en-US) and other languages stored in language related subfolders. + + General information about PowerShell support for internationalization, please read Get-Help about_Script_Internationalization. + + The tests created initially for the Format-Pester project - https://github.com/equelin/format-pester - internationalization supported since v. 1.3.0. + + .LINK + https://github.com/equelin/Format-Pester + + .NOTES + AUTHOR: Wojciech Sciesinski, wojciech[at]sciesinski[dot]net + KEYWORDS: PowerShell, Translation, Pester, psd1 + + VERSIONS HISTORY + 0.1.0 - 2016-07-30 - The first version + 0.2.0 - 2016-08-02 - Checking if null/empty strings are used, messages for failed tests improved + 0.3.0 - 2016-08-09 - Names of variables used in code generalized, base names located at the begining of code + 0.3.1 - 2016-09-04 - Some tests corrected + + TODO + - improve performance for testing in context "Check translation for $SubfolderInPublicName - detailed fields name comparison" - based on the previously calculated difference + - add support for multi functions modules + + REMARKS + - Tests for check encoding used for translation files based on the 4 bytes of data (BOM) are the waste of time - due that some editors don't set this bytes e.g. Notepad++ + + LICENSE + Copyright (c) 2016 Wojciech Sciesinski + This function is licensed under The MIT License (MIT) + Full license text: https://opensource.org/licenses/MIT + +#> + +$ModuleName = 'Format-Pester' + +$BaseTranslationFileName = 'Format-Pester.psd1' + +New-Variable -Scope Global -Name GlobalModuleName -Value $ModuleName -Force + +New-Variable -Scope Global -Name GlobalBaseTranslationFileName -Value $BaseTranslationFileName -Force + +[scriptblock]$ModuleVersionReturned = { Format-Pester -Version } + +Describe -Name "Unit tests for $GlobalModuleName translations" -Tag 'Translations' { + + BeforeAll { + + Remove-Module -Name $GlobalModuleName -ErrorAction SilentlyContinue + + Import-Module "$PSScriptRoot\..\$GlobalModuleName" -Force -Scope Global -ErrorAction Stop + + } + + AfterAll { + + #Remove previously defined variables scoped as global + + $VariablesToRemove = @('GlobalModuleName', 'GlobalBaseTranslationFileName', 'enUSLocalizedStrings1', 'enUSLocalizedStrings2', 'GlobalenUSLocalizedStrings', 'GlobalenUSLocalizedStringCount', 'GlobalenUSLocalizedStringKeys', ` + 'SkipDueEnUSNotImported', 'GlobalCurrentLanguageLocalizedStringCount', 'GlobalCurrentLanguageLocalizedStringKeys', 'DifferencesInKeys', 'KeysNotEqual') + + ForEach ($VariableToRemove in $VariablesToRemove) { + + Remove-Variable -Scope Global -Name $VariableToRemove -Force -ErrorAction SilentlyContinue + + } + + } + + $Module = $(Get-Module -Name $GlobalModuleName) + + $ModuleVersion = $([Version]$Module.Version).ToString() + + $ModulePath = $([System.IO.FileInfo]$Module.Path).DirectoryName + + Context "Compare versions numbers included in module of $GlobalModuleName module and function" { + + It 'Compare versions numbers between module and function' { + + $ModuleVersion | Should be $(& $ModuleVersionReturned) + + } + + } + + Context 'Check the subfolder en-US - main language' { + + $enUSfolderInPublic = Get-Item -Path "$ModulePath\Public\en-US" -ErrorAction SilentlyContinue + + It 'Check if the en-US folder exist' { + { Test-Path -Path $enUSfolderInPublic -PathType Container } | Should be $true + + } + + It "Check if the subfolder en-US contains $GlobalBaseTranslationFileName file " { + { Test-Path -Path "$enUSfolderInPublic\$GlobalBaseTranslationFileName" -PathType Leaf } | Should be $true + + } + + It "Check if $BaseTranslationFileName from en-US folder can be imported" { + { Import-LocalizedData -BaseDirectory $("$ModulePath\Public") -FileName $GlobalBaseTranslationFileName -BindingVariable enUSLocalizedStrings1 -UICulture 'en-US' -ErrorAction SilentlyContinue } | Should Not Throw + + Import-LocalizedData -BaseDirectory $("$ModulePath\Public") -FileName $GlobalBaseTranslationFileName -BindingVariable enUSLocalizedStrings2 -UICulture 'en-US' + + New-Variable -Scope Global -Name GlobalenUSLocalizedStrings -Value $enUSLocalizedStrings2 + + New-Variable -Scope Global -Name GlobalenUSLocalizedStringCount -Value $enUSLocalizedStrings2.Count -Force + + New-Variable -Scope Global -Name GlobalenUSLocalizedStringKeys -Value $enUSLocalizedStrings2.Keys -Force + + $GlobalenUSLocalizedStrings = $GlobalenUSLocalizedStrings.GetEnumerator() | Sort-Object -Property Name + + $GlobalenUSLocalizedStringKeys = $GlobalenUSLocalizedStringKeys | Sort-Object + + } + + It "Check if data from the file $BaseTranslationFileName for en-US was correctly assigned to variable." { + + $GlobalenUSLocalizedStringCount | Should BeGreaterThan 0 + + } + + It "Compare version of en-US translation with version of module" { + + $GlobalenUSLocalizedStrings.msg00 | Should be $ModuleVersion + + } + + #Enumerate hashtable and check if keys has assigned values (translations strings are fullfilled) + $GlobalenUSLocalizedStrings.GetEnumerator() | ForEach-Object -Process { + + $CurrentenUSLocalizedStringValue = $_ + + If ([String]::IsNullOrEmpty($CurrentenUSLocalizedStringValue.Value)) { + + It "Check if value for $($_.Key) for en-US is not null or empty." { + + $CurrentenUSLocalizedStringValue.Value | Should Not BeNullOrEmpty + + } + + } + + } + + } + + $SubfoldersInPublic = Get-ChildItem -Path "$ModulePath\Public\" -Directory + + ForEach ($SubfolderInPublic in $SubfoldersInPublic) { + + $SubfolderInPublicName = $SubfolderInPublic.Name + + If ($SubfolderInPublicName -ne 'en-US') { + + Context "Check translations for subfolder $SubfolderInPublicName" { + + $SubfolderInPublicNamePath = $SubfolderInPublic.FullName + + It "Check subfolder name format for the folder $SubfolderInPublicName" { + + $SubfolderInPublicName.Substring(2, 1) | Should be '-' + + } + + It "Check if the subfolder $SubfolderInPublicName contains $BaseTranslationFileName file " { + { Test-Path -Path "$SubfolderInPublicNamePath\Format-Pester.psd1" -PathType Leaf } | Should be $true + + } + + It "Check if $GlobalBaseTranslationFileName from $SubfolderInPublicName folder can be imported and contains data" { + { Import-LocalizedData -BaseDirectory $("$ModulePath\Public") -FileName $GlobalBaseTranslationFileName -BindingVariable CurrentLanguageLocalizedStrings1 -UICulture $SubfolderInPublicName -ErrorAction SilentlyContinue } | Should Not Throw + + Import-LocalizedData -BaseDirectory $("$ModulePath\Public") -FileName $GlobalBaseTranslationFileName -BindingVariable CurrentLanguageLocalizedStrings2 -UICulture $SubfolderInPublicName -ErrorAction SilentlyContinue + + New-Variable -Scope Global -Name GlobalCurrentLanguageLocalizedStrings -Value $CurrentLanguageLocalizedStrings2 -Force + + New-Variable -Scope Global -Name GlobalCurrentLanguageLocalizedStringCount -Value $CurrentLanguageLocalizedStrings2.Count -Force + + New-Variable -Scope Global -Name GlobalCurrentLanguageLocalizedStringKeys -Value $CurrentLanguageLocalizedStrings2.Keys -Force + + $GlobalCurrentLanguageLocalizedStrings = $GlobalCurrentLanguageLocalizedStrings.GetEnumerator() | Sort-Object -Property Name + + $GlobalCurrentLanguageLocalizedStringKeys = $GlobalCurrentLanguageLocalizedStringKeys | Sort-Object + + } + + It "Check if data from the file $BaseTranslationFileName for $SubfolderInPublicName was correctly assigned to variable." { + + $GlobalCurrentLanguageLocalizedStringCount | Should BeGreaterThan 0 + + } + + It "Compare version of $SubfolderInPublicName translation with version of module" { + + $GlobalCurrentLanguageLocalizedStrings.msg00 | Should be $ModuleVersion + + } + + It "Compare amount of strings for en-US and $SubfolderInPublicName" { + + $GlobalenUSLocalizedStringCount | Should be $GlobalCurrentLanguageLocalizedStringCount + + } + + #Enumerate hashtable and check if keys has assigned values (translations strings are fullfilled) + $GlobalCurrentLanguageLocalizedStrings.GetEnumerator() | ForEach-Object -Process { + + $CurrentCurrentLanguageLocalizedStringValue = $_ + + If ([String]::IsNullOrEmpty($CurrentCurrentLanguageLocalizedStringValue.Value)) { + + It "Check if value for $($_.Key) for en-US is not null or empty." { + + $CurrentCurrentLanguageLocalizedStringValue.Value | Should Not BeNullOrEmpty + + } + + } + + } + + It "Compare if names of localization keys for en-US and $SubfolderInPublicName are equal" { + + $DifferencesInKeys = Compare-Object -ReferenceObject $GlobalenUSLocalizedStringKeys -DifferenceObject $GlobalCurrentLanguageLocalizedStringKeys + + If ($DifferencesInKeys) { + + New-Variable -Name KeysNotEqual -Value $true -Scope Global -Force + + #New-Variable -Name GlobalDifferencesInKeys -Value $DifferencesInKeys -Scope Global -Force + + } + + $KeysNotEqual | Should BeNullOrEmpty + + } + + } + + If ($KeysNotEqual) { + + Context "Check translation for $SubfolderInPublicName - detailed fields name comparison" { + + ForEach ($CurrentenUSLocalizedKey in $GlobalenUSLocalizedStringKeys) { + + if ($GlobalCurrentLanguageLocalizedStringKeys -notcontains $CurrentenUSLocalizedKey) { + + It "The language file $SubfolderInPublicName not contains $CurrentenUSLocalizedKey" { + + $CurrentLanguageContainResult = ($GlobalCurrentLanguageLocalizedStringKeys -contains $CurrentenUSLocalizedKey) + + $CurrentLanguageContainResult | Should be $true + + } + + } + + } + + ForEach ($CurrentenLanguageLocalizedKey in $GlobalCurrentLanguageLocalizedStringKeys) { + + if ($GlobalenUSLocalizedStringKeys -notcontains $CurrentenLanguageLocalizedKey) { + + It "The language file en-US does not contain $CurrentenLanguageLocalizedKey available in $SubfolderInPublicName" { + + $EnUSLanguageContainResult = ($GlobalenUSLocalizedStringKeys -contains $CurrentenLanguageLocalizedKey) + + $EnUSLanguageContainResult | Should be $true + + } + + } + + } + + } + + } + + } + + } + } \ No newline at end of file