Testing

run

Starts test suite after is defined. Usually at the bottom of your Program.fs

1: 
run()

runFor

Starts test suite and runs the suite with each of the listed browsers. Usually at the bottom of your Program.fs

1: 
2: 
//TODO Dotnet doesn't allow vague type definitions
//runFor [chrome; firefox; ie]

context

Define the context of the tests. A default context is defined and used if one is not provided. You can have as many contexts as you like. Each context gets a new once/before/after/lastly function.

1: 
2: 
3: 
4: 
5: 
6: 
7: 
8: 
context "Login page tests"
//some tests

context "Search page tests"
//different tests

context "Reset password page tests"
//different tests

once

Function that is run once time at the beginning of a test suite. (per context)

1: 
2: 
3: 
once (fun _ ->
    ()//do this one time at the beginning of the most recently defined context
)

before

Function that is run before each test in a context. (per context)

1: 
2: 
3: 
before (fun _ ->
    ()//do this before every test of the most recently defined context
)

after

Function that is run after each test in a context. (per context)

1: 
2: 
3: 
after (fun _ ->
    ()//do this after every test of the most recently defined context
)

lastly

Function that is run once at the end of a context. (per context)

1: 
2: 
3: 
lastly (fun _ ->
    ()//do this after the very last test of the most recently defined context
)

onPass

Function that is run after a test passes. (per context)

1: 
2: 
3: 
onPass (fun _ ->
    ()//do this after a test passes
)

onFail

Function that is run after a test fails. (per context)

1: 
2: 
3: 
onFail (fun _ ->
    ()//do this after a test fails
)

test

Standard test definition (name defined automatically by the test number eg: Test #1).

1: 
2: 
3: 
4: 
5: 
6: 
test (fun _ ->
    //go somewhere
    //interact with page
    //assert
    ()
)

&&& (named test, aliased as ntest)

Standard test definition with a name.

 1: 
 2: 
 3: 
 4: 
 5: 
 6: 
 7: 
 8: 
 9: 
10: 
11: 
12: 
"go somewhere, do some stuff, assert" &&& fun _ ->
    //go somewhere
    //interact with page
    //assert
    ()
//Or
ntest "go somewhere, do some stuff, assert" (fun _ ->
    //go somewhere
    //interact with page
    //assert
    ()
)

&&&& (work in progress, aliased as wip)

Used for debugging. Test runs slower and highlights the elements that it is interacting with to help debug. If one test is marked wip, only wip tests are ran. Other tests are skipped.

 1: 
 2: 
 3: 
 4: 
 5: 
 6: 
 7: 
 8: 
 9: 
10: 
11: 
12: 
13: 
//this test is run slow and only with other tests marked as wip
"go somewhere, do some stuff, assert" &&&& fun _ ->
    //go somewhere
    //interact with page
    //assert
    ()
//Or
wip (fun _ ->
    //go somewhere
    //interact with page
    //assert
    ()
)

&&! (skip, aliased as xtest)

Do not run a test.

 1: 
 2: 
 3: 
 4: 
 5: 
 6: 
 7: 
 8: 
 9: 
10: 
11: 
12: 
13: 
//skipped
"go somewhere, do some stuff, assert" &&! fun _ ->
    //go somewhere
    //interact with page
    //assert
    ()
//Or
xtest (fun _ ->
    //go somewhere
    //interact with page
    //assert
    ()
)

&&&&& (always run, in both standard and wip modes)

Test will always be run. If some tests are marked work in progress, tests marked as always will also run. The test will run slow with wip tests, but run at normal speed when there are no wip tests.

1: 
2: 
3: 
4: 
5: 
6: 
//this test is run slow with wip test and regular speed with standard tests, test will always run.
"go somewhere, do some stuff, assert" &&&&& fun _ ->
    //go somewhere
    //interact with page
    //assert
    ()

many

Run a single test X times. Helps with troubleshooting tests that sometimes fail.

1: 
2: 
3: 
4: 
5: 
6: 
many 20 (fun _ ->
    //go somewhere
    //interact with page
    //assert
    ()
)

nmany

Run a single named test X times. Helps with troubleshooting tests that sometimes fail.

1: 
2: 
3: 
4: 
5: 
6: 
nmany 20 "description" (fun _ ->
    //go somewhere
    //interact with page
    //assert
    ()
)

todo

Mark a test as todo to fill in later. LiveHtmlReporter will mark todo tests in the output.

1: 
"go somewhere, do some stuff, assert" &&& todo
namespace canopy
module classic

from canopy
namespace canopy.runner
module classic

from canopy.runner
namespace System
module types

from canopy
val run : unit -> unit
val context : c:string -> unit
val once : f:(unit -> unit) -> unit
val before : f:(unit -> unit) -> unit
val after : f:(unit -> unit) -> unit
val lastly : f:(unit -> unit) -> unit
val onPass : f:(unit -> unit) -> unit
val onFail : f:(unit -> unit) -> unit
val test : f:(unit -> unit) -> unit
val ntest : description:string -> f:(unit -> unit) -> unit
val wip : f:(unit -> unit) -> unit
val xtest : f:'a -> unit
val many : count:int -> f:(unit -> unit) -> unit
val nmany : count:int -> description:string -> f:(unit -> unit) -> unit
val mutable todo : (unit -> unit)