From 879481fca69a26fa8fcb2bda254f2a1fce8c2c7a Mon Sep 17 00:00:00 2001 From: Chris Holt Date: Sun, 31 Jul 2016 11:30:23 -0500 Subject: [PATCH] Add ability to skip in the middle of a test, for #280 --- src/canopy/canopy.fs | 4 ++++ src/canopy/runner.fs | 10 +++++++--- src/canopy/types.fs | 1 + tests/basictests/Program.fs | 3 ++- 4 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/canopy/canopy.fs b/src/canopy/canopy.fs index 90c2f37a..b4b89395 100644 --- a/src/canopy/canopy.fs +++ b/src/canopy/canopy.fs @@ -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() \ No newline at end of file diff --git a/src/canopy/runner.fs b/src/canopy/runner.fs index b08790c5..1e88108f 100644 --- a/src/canopy/runner.fs +++ b/src/canopy/runner.fs @@ -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 @@ -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 diff --git a/src/canopy/types.fs b/src/canopy/types.fs index 4ddf0efa..8dfa7c70 100644 --- a/src/canopy/types.fs +++ b/src/canopy/types.fs @@ -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 = diff --git a/tests/basictests/Program.fs b/tests/basictests/Program.fs index 5223b665..9474f46d 100644 --- a/tests/basictests/Program.fs +++ b/tests/basictests/Program.fs @@ -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") @@ -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"