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

Set name in xml element testsuite #2034

merged 6 commits into from Aug 17, 2021

Conversation

Marc013
Copy link
Contributor

@Marc013 Marc013 commented Jul 21, 2021

PR Summary

Fixes #2033

Pester configuration 'TestResult.TestSuiteName' sets name in element 'test-results' instead of name in first element 'test-suite'

@nohwnd
Copy link
Member

nohwnd commented Jul 21, 2021

Please add a test for this so we avoid regressions.

Comment on lines 327 to 328
$suiteInfo = Get-TestSuiteInfo -TestSuite $Result -Path "Pester"
$suiteInfo.name = $RunResult.Configuration.TestResult.TestSuiteName.Value
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can merge this if you want. -Path is used for name and description IIRC.

@Marc013
Copy link
Contributor Author

Marc013 commented Jul 22, 2021

@nohwnd
I would love to make a unit test however, I have no clue how I can unit test the change I have implemented in function ‘Write-NUnitTestResultChildNodes’.
Can you provide any help/guidance here?

@nohwnd
Copy link
Member

nohwnd commented Jul 22, 2021

There are tests for this feature NUnit output in https://github.com/pester/Pester/blob/main/tst/Pester.RSpec.Nunit.TestResults.ts.ps1 those are P tests, P is simplified test framework that we use to test some aspects of Pester. You should be able to simply run the whole file. If that does not work run .\test.ps1 from the root of the repo first.

In that file you add a test, they use i, b and t functions, i is for invoke, b is for block (like Describe in Pester) and t is for test (like It in Pester). You can focus a single test by using dt instead of t to make development easier. Hopefully reading few other tests in the file will make it clear what is happening. You run a Pester run, and then compare the resulting XML to ensure it was produced correctly.

@Marc013
Copy link
Contributor Author

Marc013 commented Jul 23, 2021

@nohwnd,
The unit test is added. I hope it's to your satisfaction.

@fflaten
Copy link
Collaborator

fflaten commented Aug 10, 2021

Thanks @Marc013 . I made a few adjustments to clean up the "RunResult"-parameters + simplified the test. Also, didn't want to scare any DC-fans from contributing 😄

@nohwnd nohwnd merged commit 5abd7fe into pester:main Aug 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants