Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set name in xml element testsuite #2034

Merged
merged 6 commits into from
Aug 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/functions/TestResults.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -320,11 +320,12 @@ function Write-NUnitTestResultAttributes($Result, [System.Xml.XmlWriter] $XmlWri
$XmlWriter.WriteAttributeString('time', $Result.ExecutedAt.ToString('HH:mm:ss'))
}

function Write-NUnitTestResultChildNodes($RunResult, [System.Xml.XmlWriter] $XmlWriter) {
Write-NUnitEnvironmentInformation -Result $RunResult -XmlWriter $XmlWriter
Write-NUnitCultureInformation -Result $RunResult -XmlWriter $XmlWriter
function Write-NUnitTestResultChildNodes($Result, [System.Xml.XmlWriter] $XmlWriter) {
Write-NUnitEnvironmentInformation -Result $Result -XmlWriter $XmlWriter
Write-NUnitCultureInformation -Result $Result -XmlWriter $XmlWriter

$suiteInfo = Get-TestSuiteInfo -TestSuite $Result -Path "Pester"
$suiteInfo.name = $Result.Configuration.TestResult.TestSuiteName.Value

$XmlWriter.WriteStartElement('test-suite')

Expand Down
25 changes: 25 additions & 0 deletions tst/Pester.RSpec.Nunit.TestResults.ts.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,31 @@ i -PassThru:$PassThru {
$xmlResult.Schemas.Add($null, $schemePath) > $null
$xmlResult.Validate( { throw $args[1].Exception })
}

t 'should user TestResult.TestSuiteName configuration value as name-attribute for root test-suite' {
$sb = {
Describe 'Mocked Describe' {
It 'Successful testcase' {
$true | Should -Be $true
}
}
}

$Name = 'MyTestRun'

$Configuration = New-PesterConfiguration
$Configuration.Run.ScriptBlock = $sb
$Configuration.Run.PassThru = $true
$Configuration.TestResult.TestSuiteName = $Name
$Configuration.Output.Verbosity = 'None'

$r = Invoke-Pester -Configuration $Configuration

$xmlResult = $r | ConvertTo-NUnitReport
$xmlTestCase = $xmlResult.'test-results'.'test-suite'
$xmlTestCase.name | Verify-Equal $Name
# Also used in name for test-results-node. Undocumented, but kept for back-compat.
}
}

b 'Exporting Parameterized Tests (Newer format)' {
Expand Down