Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Strongly type runFor instead of boxing #486

Merged
merged 1 commit into from
Nov 5, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 11 additions & 14 deletions src/canopy/runner.fs
Original file line number Diff line number Diff line change
Expand Up @@ -166,12 +166,12 @@ let private runtest (suite : suite) (test : Test) =

match testResult with
| Skip -> Skip
| _ ->
| _ ->
let afterResult = tryTest test suite (suite.After)
match testResult with
| Failed -> testResult
| _ -> afterResult

failureMessage <- null
result
else
Expand Down Expand Up @@ -238,35 +238,32 @@ let run () =
reporter.suiteEnd()

(* documented/testing *)
let runFor browsers =
let runFor (browsers: Browsers) =
// suites are in reverse order and have to be reversed before running the tests
let currentSuites = suites
match box browsers with
| :? (canopy.types.BrowserStartMode list) as browsers ->

match browsers with
| BrowserStartModes browsers ->
let newSuites =
browsers
|> List.rev
|> List.map (fun browser ->
|> List.collect (fun browser ->
let suite = new suite()
suite.Context <- sprintf "Running tests with %s browser" (toString browser)
suite.Once <- fun _ -> start browser
suite.Once <- fun _ -> start browser
let currentSuites2 = currentSuites |> List.map(fun suite -> suite.Clone())
currentSuites2 |> List.iter (fun suite -> suite.Context <- sprintf "(%s) %s" (toString browser) suite.Context)
currentSuites2 @ [suite])
|> List.concat
suites <- newSuites
| :? (IWebDriver list) as browsers ->
| WebDrivers browsers ->
let newSuites =
browsers
|> List.rev
|> List.map (fun browser ->
|> List.collect (fun browser ->
let suite = new suite()
suite.Context <- sprintf "Running tests with %s browser" (browser.ToString())
suite.Context <- sprintf "Running tests with %s browser" (browser.ToString())
suite.Once <- fun _ -> switchTo browser
let currentSuites2 = currentSuites |> List.map(fun suite -> suite.Clone())
currentSuites2 |> List.iter (fun suite -> suite.Context <- sprintf "(%s) %s" (browser.ToString()) suite.Context)
currentSuites2 @ [suite])
|> List.concat
suites <- newSuites
| _ -> raise <| Exception "I dont know what you have given me"
6 changes: 5 additions & 1 deletion src/canopy/types.fs
Original file line number Diff line number Diff line change
Expand Up @@ -111,4 +111,8 @@ type IReporter =
abstract member quit : unit -> unit
abstract member suiteBegin : unit -> unit
abstract member suiteEnd : unit -> unit
abstract member setEnvironment : string -> unit
abstract member setEnvironment : string -> unit

type Browsers =
| BrowserStartModes of BrowserStartMode list
| WebDrivers of IWebDriver list