diff --git a/test/powershell/Select-XML.Tests.ps1 b/test/powershell/Select-XML.Tests.ps1 index 4b52c584d..4ef388653 100644 --- a/test/powershell/Select-XML.Tests.ps1 +++ b/test/powershell/Select-XML.Tests.ps1 @@ -1,10 +1,8 @@ Describe "Select-XML DRT Unit Tests" -Tags DRT{ - $tmpDirectory = $TestDrive - $testfilename = "testfile.xml" - $testfile = Join-Path -Path $tmpDirectory -ChildPath $testfilename - It "Select-XML should work"{ + BeforeAll { + $testfile = Join-Path -Path $TestDrive -ChildPath "testfile.xml" $xmlContent = @" @@ -19,16 +17,15 @@ Describe "Select-XML DRT Unit Tests" -Tags DRT{ "@ $xmlContent >$testfile - try - { - $results=Select-XML -Path $testfile -XPath "/bookstore/book/title" - $results.Count | Should Be 2 - $results[0].Node."#text" | Should Be "Harry Potter" - $results[1].Node."#text" | Should Be "Learning XML" - } - finally - { - rm $testfile - } + } + AfterAll { + rm $testfile + } + + It "Select-XML should work"{ + $results = Select-XML -Path $testfile -XPath "/bookstore/book/title" + $results.Count | Should Be 2 + $results[0].Node."#text" | Should Be "Harry Potter" + $results[1].Node."#text" | Should Be "Learning XML" } }