[英]How to run a Canopy test suite with xUnit?
I decided to use canopy framework to test my UI.我决定使用canopy框架来测试我的 UI。
Most of the examples include either built-in assertion framework or Expecto .大多数示例包括内置断言框架或Expecto 。 Which are both good choices yet I use xUnit everywhere else in the project and want to be uniform for now.这两个都是不错的选择,但我在项目中的其他任何地方都使用 xUnit,现在想要统一。
For xUnit I have found only this example but it contains just two very basic tests whereas I need to things like common code to run prior to all the tests.对于 xUnit,我只找到了这个例子,但它只包含两个非常基本的测试,而我需要在所有测试之前运行通用代码之类的东西。 What would be an idiomatic way for canopy + xUnit ? canopy + xUnit的惯用方式是什么?
xUnit has class fixtures and here is an example how to bring it to F# code. xUnit 具有 类固定装置,这里是一个如何将其引入 F# 代码的示例。
Combining that with canopy scenarios, here is an example of what it can look like:将其与树冠场景相结合,以下是它的外观示例:
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
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.