【问题标题】:How to run a Canopy test suite with xUnit?如何使用 xUnit 运行 Canopy 测试套件?
【发布时间】:2021-02-11 16:53:02
【问题描述】:

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

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

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

【问题讨论】:

    标签: f# xunit ui-testing canopy-web-testing


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-12-21
      • 2015-11-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多