如何 运行 使用 xUnit 的 Canopy 测试套件?

How to run a Canopy test suite with xUnit?

我决定使用 canopy 框架来测试我的 UI。

大多数示例都包含 built-in assertion framework or Expecto。这两个都是不错的选择,但我在项目的其他任何地方都使用 xUnit,并且现在想要统一。

对于 xUnit,我只找到了 this example,但它只包含两个非常基本的测试,而在所有测试之前,我需要像 运行 这样的通用代码。 canopy + xUnit 的惯用方式是什么?

xUnit 有 class fixtures and here 是如何将其引入 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