Skip to content

Commit

Permalink
Fix JUnit counts for skipped and notrun (pester#1758)
Browse files Browse the repository at this point in the history
  • Loading branch information
nohwnd authored Nov 1, 2020
1 parent d96f992 commit ed24b0d
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/functions/TestResults.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ function Write-JUnitTestSuiteAttributes($Action, [System.Xml.XmlWriter] $XmlWrit
$XmlWriter.WriteAttributeString('hostname', $environment.'machine-name')
$XmlWriter.WriteAttributeString('id', $Id)
$XmlWriter.WriteAttributeString('skipped', $Action.SkippedCount)
$XmlWriter.WriteAttributeString('disabled', $Action.InconclusiveCount + $Action.PendingCount)
$XmlWriter.WriteAttributeString('disabled', $Action.NotRunCount)
$XmlWriter.WriteAttributeString('package', $Package)
$XmlWriter.WriteAttributeString('time', $Action.Duration.TotalSeconds.ToString('0.000', [System.Globalization.CultureInfo]::InvariantCulture))

Expand Down
31 changes: 31 additions & 0 deletions tst/Pester.RSpec.Junit.TestResults.ts.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,37 @@ i -PassThru:$PassThru {
$stackTraceText[0] | Verify-Equal "at <ScriptBlock>, ${PSCommandPath}:$failureLine"
}

t "should write skipped and filtered test results counts" {
$sb = {
Describe "Mocked Describe" {
It "Successful testcase" {
$true | Should -Be $true
}

It "Failed testcase" {
$true | Should -Be $false
}

It "Skipped testcase" -Skip {
$true | Should -Be $true
}

It "Filtered-out testcase" -Tag "exclude" {
$true | Should -Be $true
}
}
}

$r = Invoke-Pester -Container (New-PesterContainer -ScriptBlock $sb) -PassThru -Output None -ExcludeTag "exclude"

$xmlResult = $r | ConvertTo-JUnitReport
$xmlTestSuite = $xmlResult.'testsuites'.'testsuite'
$xmlTestSuite.tests | Verify-Equal 4
$xmlTestSuite.failures | Verify-Equal 1
$xmlTestSuite.skipped | Verify-Equal 1
$xmlTestSuite.disabled | Verify-Equal 1
}

t "should write a failed test result when there are multiple errors" {
$sb = {
Describe "Mocked Describe" {
Expand Down

0 comments on commit ed24b0d

Please sign in to comment.