我试图弄清楚如何让 Canopy 的测试结果显示在 VS 测试资源管理器中。我可以让我的测试显示出来,它会运行它们,但它总是显示通过。似乎 Run() 函数正在“吃掉”结果,因此 VS 永远不会看到失败。
我确信 Canopy 如何很好地解释它进入测试结果的异常之间存在冲突,因为通常您希望 Run() 无论结果如何都能成功并使用自己的报告报告其结果。
也许我应该在 MS 测试代码中重定向输出并解释它?
所以这就是我现在设置它的方式......
Visual Studio Test Runner 会查看此文件中的测试内容,这些测试调用执行真正测试的 canopy 方法。
open canopy
open runner
open System
open Microsoft.VisualStudio.TestTools.UnitTesting
[<TestClass>]
type testrun() =
// Look in the output directory for the web drivers
[<ClassInitialize>]
static member public setup(context : TestContext) =
// Look in the output directory for the web drivers
canopy.configuration.ieDir <- "."
canopy.configuration.chromeDir <- "."
// start an instance of the browser
start ie
()
[<TestMethod>]
member x.LocationNoteTest() =
let myTestModule = new myTestModule()
myTestModule.all()
run()
[<ClassCleanup>]
static member public cleanUpAfterTesting() =
quit()
()
myTestModule 看起来像
open canopy
open runner
open System
type myTestModule() =
// some helper methods
member x.basicCreate() =
context "The meat of my tests"
"Test1" &&& fun _ ->
// some canopy test statements like...
url "http://theURL.com/"
"#title" == "The title of my page"
//Does the text of the button match expectations?
"#addLocation" == "LOCATION"
// add a location note
click ".btn-Location"
member x.all() =
x.basicCreate()
// I could add additional tests here or I could decide to call them individually