Skip to content

Commit

Permalink
added ability to mark a test you expect to fail with an error message…
Browse files Browse the repository at this point in the history
…, 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
lefthandedgoat committed Apr 4, 2012
1 parent 25b8ce5 commit a1d9bb4
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 12 deletions.
9 changes: 6 additions & 3 deletions basictests/Program.fs
Original file line number Diff line number Diff line change
Expand Up @@ -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 ()
Expand Down
2 changes: 1 addition & 1 deletion canopy.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
6 changes: 5 additions & 1 deletion canopy/canopy.fs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -252,4 +253,7 @@ let sleep seconds =

let reload _ =
url (currentUrl ())
url (currentUrl ())

let failswith message =
failuremessage <- message
18 changes: 11 additions & 7 deletions canopy/runner.fs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit a1d9bb4

Please sign in to comment.