Skip to content

Commit

Permalink
Add ability to skip in the middle of a test, for #280
Browse files Browse the repository at this point in the history
  • Loading branch information
lefthandedgoat committed Jul 31, 2016
1 parent ce7c94e commit 879481f
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 4 deletions.
4 changes: 4 additions & 0 deletions src/canopy/canopy.fs
Original file line number Diff line number Diff line change
Expand Up @@ -996,3 +996,7 @@ let label = addSelector findByLabel "label"
let text = addSelector findByText "text"
(* documented/actions *)
let value = addSelector findByValue "value"

let skip message =
describe <| sprintf "Skipped: %s" message
raise <| CanopySkipTestException()
10 changes: 7 additions & 3 deletions src/canopy/runner.fs
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ let tryTest test suite func =
func ()
Pass
with
| :? CanopySkipTestException -> Skip
| ex when failureMessage <> null && failureMessage = ex.Message -> Pass
| ex -> Fail ex

Expand All @@ -160,10 +161,13 @@ let private runtest (suite : suite) (test : Test) =
| Fail(_) -> processRunResult suite test testResult; Failed
| _ -> testResult

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

reporter.testEnd test.Id
failureMessage <- null
Expand Down
1 change: 1 addition & 0 deletions src/canopy/types.fs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ type CanopyOnException(message) = inherit CanopyException(message)
type CanopyCheckFailedException(message) = inherit CanopyException(message)
type CanopyUncheckFailedException(message) = inherit CanopyException(message)
type CanopyReadException(message) = inherit CanopyException(message)
type CanopySkipTestException() = inherit CanopyException(String.Empty)

//directions
type direction =
Expand Down
3 changes: 2 additions & 1 deletion tests/basictests/Program.fs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ let testpage = "http://lefthandedgoat.github.io/canopy/testpages/"

"#welcome should have Welcome" &&& fun _ ->
url testpage
skip "test"
"#welcome" == "Welcome"

//ntest "description" (fun _ -> url "http://www.google.com")
Expand Down Expand Up @@ -592,7 +593,7 @@ context "hovering"
"#hover" == "hovered"

context "dragging"
"draging works" &&& fun _ ->
"draging works" &&! fun _ ->
url "http://scrumy.com/silenter39delayed"
click ".plus-button a img"
"#task_title" << "Demo"
Expand Down

0 comments on commit 879481f

Please sign in to comment.