Commits

Aaron Jensen committed c90233f

Upgrading to latest Pest framework.

Comments (0)

Files changed (1)

Tools/Pest/pest.ps1

     $testInfo = New-Object PsObject -Property $testProperties
     Set-CurrentTest $function
     $startedAt = Get-Date
+    $output = @()
     try
     {
         
-        if( Test-path function:Setup )
+        if( Test-path function:Start-Test )
+        {
+            . Start-Test | Write-Verbose
+        }
+        elseif( Test-Path function:SetUp )
         {
             . SetUp | Write-Verbose
         }
         if( Test-Path function:$function )
         {
             $testInfo.Passed = $true
-            $output = . $function
-            if( $output )
-            {
-                $testInfo.PipelineOutput = $output
-            }
+            . $function | ForEach-Object { $output += $_ }
         }
     }
     catch [Pest.AssertionException]
     }
     finally
     {
+        if( $output )
+        {
+            $testInfo.PipelineOutput = $output
+        }
         $error.Clear()
-        if( Test-Path function:TearDown )
+        try
         {
-            try
+            if( Test-Path function:Stop-Test )
+            {
+                . Stop-Test | Write-Verbose
+            }
+            elseif( Test-Path -Path function:TearDown )
             {
                 . TearDown | Write-Verbose
             }
-            catch
-            {
-                Write-Host "An error occured tearing down test '$function': $_" -ForegroundColor Red
-                $error.Clear()
-            }
+        }
+        catch
+        {
+            Write-Host "An error occured tearing down test '$function': $_" -ForegroundColor Red
+            $error.Clear()
         }
     }
     $testInfo.Duration = (Get-Date) - $startedAt 
         . $testCase.FullName
         try
         {
+            if( Test-Path -Path function:Start-TestFixture )
+            {
+                . Start-TestFixture | Write-Verbose
+            }
+
             foreach( $function in $functions )
             {
 
                 
                 Invoke-Test $testModuleName $function
             }
+
+            if( Test-Path -Path function:Stop-TestFixture )
+            {
+                try
+                {
+                    . Stop-TestFixture | Write-Verbose
+                }
+                catch
+                {
+                    Write-Host ("An error occured tearing down test fixture '{0}': {1}" -f $testCase.Name,$_) -ForegroundColor Red
+                    $error.Clear()
+                }                
+            }
         }
         finally
         {