Skip to content

Commit

Permalink
Merge pull request #150 from soerennielsen/ReporterFailExceptionFix
Browse files Browse the repository at this point in the history
Reporter fail exception fix
  • Loading branch information
lefthandedgoat committed May 17, 2014
2 parents e008012 + 580489e commit cd66eef
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
4 changes: 3 additions & 1 deletion src/canopy/configuration.fs
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
module canopy.configuration
open reporters
open System

//runner related
let failFast = ref false
let failScreenshotPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\canopy\"

let mutable chromeDir = @"c:\"
let mutable ieDir = @"c:\"
Expand All @@ -16,4 +18,4 @@ let mutable reporter : IReporter = new ConsoleReporter() :> IReporter
let mutable disableSuggestOtherSelectors = false
let mutable autoPinBrowserRightOnLaunch = true
let mutable throwIfMoreThanOneElement = false
let mutable configuredFinders = finders.defaultFinders
let mutable configuredFinders = finders.defaultFinders
21 changes: 14 additions & 7 deletions src/canopy/runner.fs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ open configuration
open canopy
open reporters
open types
open OpenQA.Selenium

let rec private last = function
| hd :: [] -> hd
Expand Down Expand Up @@ -47,13 +48,19 @@ let pass () =
reporter.pass ()

let fail (ex : Exception) id =
if failFast = ref true then failed <- true
failedCount <- failedCount + 1
contextFailed <- true
let p = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\canopy\"
let f = DateTime.Now.ToString("MMM-d_HH-mm-ss-fff")
let ss = screenshot p f
reporter.fail ex id ss
try
if failFast = ref true then failed <- true
failedCount <- failedCount + 1
contextFailed <- true
let f = DateTime.Now.ToString("MMM-d_HH-mm-ss-fff")
let ss = screenshot configuration.failScreenshotPath f
reporter.fail ex id ss
with
| :? WebDriverException as failExc ->
//Fail during error report (likely OpenQA.Selenium.WebDriverException.WebDriverTimeoutException ).
// Don't fail the runner itself, but report it.
reporter.write (sprintf "Error during fail reporting: %s" (failExc.ToString()))
reporter.fail ex id null

let run () =
reporter.suiteBegin()
Expand Down

0 comments on commit cd66eef

Please sign in to comment.