Skip to content
Browse files

added ability to mark a test you expect to fail with an error message…

…, if it fails with that message it will pass. Helps with testing expected failures to make sure the framework is acting as expected
  • Loading branch information...
1 parent 25b8ce5 commit a1d9bb45f0d255ba8b2060b85b898e3e3988507f @lefthandedgoat committed Apr 3, 2012
Showing with 23 additions and 12 deletions.
  1. +6 −3 basictests/Program.fs
  2. +1 −1 canopy.nuspec
  3. +5 −1 canopy/canopy.fs
  4. +11 −7 canopy/runner.fs
View
9 basictests/Program.fs
@@ -181,17 +181,20 @@ test (fun _ ->
test (fun _ ->
describe "readonly should throw error on read only field with clear"
- !^ "http://localhost:4567/readonly"
+ failswith "element #read_only is marked as read only, you can not clear read only elements"
+ !^ "http://localhost:4567/readonly"
clear "#read_only")
test (fun _ ->
describe "readonly should throw error on read only field with write"
- !^ "http://localhost:4567/readonly"
+ failswith "element #read_only is marked as read only, you can not write to read only elements"
+ !^ "http://localhost:4567/readonly"
"#read_only" << "new text")
test (fun _ ->
describe "when value is wrong and changes to empty string prior to time out, it should show wrong value, not empty string"
- url testpage
+ failswith "equality check failed. expected: John1, got: John"
+ url testpage
"#firstName" == "John1")
run ()
View
2 canopy.nuspec
@@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata>
<id>canopy</id>
- <version>0.2.2</version>
+ <version>0.2.3</version>
<authors>Chris Holt</authors>
<owners>Chris Holt</owners>
<licenseUrl>https://github.com/lefthandedgoat/canopy/blob/master/license.txt</licenseUrl>
View
6 canopy/canopy.fs
@@ -13,6 +13,7 @@ let mutable chromedir = @"c:\"
let mutable elementTimeout = 3.0
let mutable compareTimeout = 3.0
let mutable pageTimeout = 10.0
+let mutable (failuremessage : string) = null
//keys
let tab = Keys.Tab
@@ -252,4 +253,7 @@ let sleep seconds =
let reload _ =
- url (currentUrl ())
+ url (currentUrl ())
+
+let failswith message =
+ failuremessage <- message
View
18 canopy/runner.fs
@@ -45,17 +45,21 @@ let run _ =
System.Console.WriteLine("Passed");
passedCount <- passedCount + 1
with
- | ex -> (
- if failfast = ref true then
- failed := true
- System.Console.WriteLine("failfast was set to true and an error occured; stopping testing");
- System.Console.WriteLine("Error: {0}", ex.Message);
- failedCount <- failedCount + 1
- )
+ | ex when failuremessage <> null && failuremessage = ex.Message ->
+ System.Console.WriteLine("Passed");
+ passedCount <- passedCount + 1
+ | ex ->
+ if failfast = ref true then
+ failed := true
+ System.Console.WriteLine("failfast was set to true and an error occured; testing stopped");
+ System.Console.WriteLine("Error: {0}", ex.Message);
+ failedCount <- failedCount + 1
+
if suggestions = ref true then
makeSuggestions actions
actions <- []
+ failuremessage <- null
()
if wips.IsEmpty = false then

0 comments on commit a1d9bb4

Please sign in to comment.
Something went wrong with that request. Please try again.