From f1a7950fd7f693a7a613e938f4c161ac50ecc4f8 Mon Sep 17 00:00:00 2001 From: Ruben Oen Date: Mon, 18 Jan 2016 13:55:35 +0100 Subject: [PATCH] Fixed screenshots running after after-hook --- src/canopy/runner.fs | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/src/canopy/runner.fs b/src/canopy/runner.fs index 296d97f4..cf2e3a82 100644 --- a/src/canopy/runner.fs +++ b/src/canopy/runner.fs @@ -98,6 +98,13 @@ let failSuite (ex: Exception) (suite : suite) = |> List.rev |> List.iter (fun test -> reportFailedTest ex test) +let tryTest test suite func = + try + func () + with + | ex when failureMessage <> null && failureMessage = ex.Message -> pass() + | ex -> fail ex test suite <| safelyGetUrl() + let run () = reporter.suiteBegin() let stopWatch = new Diagnostics.Stopwatch() @@ -113,17 +120,9 @@ let run () = else if skipNextTest = true then skip test.Id else - try - try - suite.Before () - test.Func () - finally - suite.After () - pass() - with - | ex when failureMessage <> null && failureMessage = ex.Message -> pass() - | ex -> fail ex test suite <| safelyGetUrl() - + tryTest test suite (suite.Before >> test.Func) + tryTest test suite (suite.After >> pass) + reporter.testEnd test.Id failureMessage <- null