From 6fae98ad39324c339cc646fbde05bc2ee7a25fe8 Mon Sep 17 00:00:00 2001 From: Chris Holt Date: Thu, 24 Mar 2016 14:13:21 -0600 Subject: [PATCH] Fix #247 fail will screenshot actions taken in after --- src/canopy/runner.fs | 26 ++++++++++++++++---------- src/canopy/types.fs | 3 ++- 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/src/canopy/runner.fs b/src/canopy/runner.fs index 5cffc48b..7e76294f 100644 --- a/src/canopy/runner.fs +++ b/src/canopy/runner.fs @@ -113,6 +113,15 @@ let tryTest test suite func = | ex when failureMessage <> null && failureMessage = ex.Message -> Pass | ex -> Fail ex +let private processRunResult suite (test : Test) result = + match result with + | Pass -> pass test.Id + | Fail ex -> fail ex test suite false <| safelyGetUrl() + | Skip -> skip test.Id + | Todo -> reporter.todo test.Id + | FailFast -> () + | Failed -> () + let private runtest (suite : suite) (test : Test) = if failed = false then reporter.testStart test.Id @@ -121,10 +130,15 @@ let private runtest (suite : suite) (test : Test) = else if System.Object.ReferenceEquals(test.Func, skipped) then Skip else if skipNextTest = true then Skip else - let testResult = tryTest test suite (suite.Before >> test.Func) + let testResult = + let testResult = tryTest test suite (suite.Before >> test.Func) + match testResult with + | Fail(_) -> processRunResult suite test testResult; Failed + | _ -> testResult + let afterResult = tryTest test suite (suite.After) match testResult with - | Fail(_) -> testResult + | Failed -> testResult | _ -> afterResult reporter.testEnd test.Id @@ -134,14 +148,6 @@ let private runtest (suite : suite) (test : Test) = failureMessage <- null FailFast -let processRunResult suite (test : Test) result = - match result with - | Pass -> pass test.Id - | Fail ex -> fail ex test suite false <| safelyGetUrl() - | Skip -> skip test.Id - | Todo -> reporter.todo test.Id - | FailFast -> () - let run () = reporter.suiteBegin() let stopWatch = new Diagnostics.Stopwatch() diff --git a/src/canopy/types.fs b/src/canopy/types.fs index 75091bc9..3050e172 100644 --- a/src/canopy/types.fs +++ b/src/canopy/types.fs @@ -85,4 +85,5 @@ type Result = | Fail of Exception | Skip | Todo - | FailFast \ No newline at end of file + | FailFast + | Failed \ No newline at end of file