1

Is there a way to add an owner per test to the NUnit results exported by Pester?

What I’m hoping to do is notify the owner via teams or email through an Azure devops pipeline (I don’t have this fully sorted yet). As a start I think I’ll need the option to add an owner per test.

  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. – Community Feb 01 '22 at 17:43

1 Answers1

0

There's no functionality explicitly in Pester for identifying a test owner. You can add Tags to tests, but it doesn't look like Tags are exported anywhere in the NUnit results. I think the only option for now would be to add an owner into the title of the test, and then parse that out from the NUnit results:

Describe 'My Tests' {

    It 'Should be true [owner: Mark Wragg]' {
        $true | Should -Be $true
    }

    It 'Should be false [owner: Mark Wragg]' {
        $true | Should -Be $true
    }

    It 'Should be true [owner: Bob Bobson]' {
        $false | Should -Be $true
    }
}

Output in NUnit file:

<results>
<test-case description="Should be true [owner: Mark Wragg]" name="My Tests.Should be true [owner: Mark Wragg]" time="0.0134" asserts="0" success="True" result="Success" executed="True" />
<test-case description="Should be false [owner: Mark Wragg]" name="My Tests.Should be false [owner: Mark Wragg]" time="0.0133" asserts="0" success="True" result="Success" executed="True" />
<test-case description="Should be true [owner: Bob Bobson]" name="My Tests.Should be true [owner: Bob Bobson]" time="0.1436" asserts="0" success="False" result="Failure" executed="True">
Mark Wragg
  • 22,105
  • 7
  • 39
  • 68