xUnit にはクラス フィクスチャがあり、これを F# コードに組み込む方法の例を次に示します。
これをキャノピー シナリオと組み合わせると、次のようになります。
open canopy.classic
open canopy.types
open System
open Xunit
let private openApp() =
...
type Fixture() =
do
start ChromeHeadless
interface IDisposable with
member _.Dispose() =
quit()
type Tests() =
interface IClassFixture<Fixture>
[<Fact>]
member _.``Soundcheck - Server is online``() =
openApp()
[<Fact>]
member _.``Button1 is enabled``() =
openApp()
let button = element "#button1"
Assert.True button.Enabled
[<Fact>]
member _.``Button2 is disabled``() =
openApp()
let button = element "#button2"
Assert.False button.Enabled