[英]Running only certain canopy tests as specified on command line
假设我有以下简单的Canopy测试程序:
open System
open canopy.runner.classic
open canopy.configuration
open canopy.classic
canopy.configuration.chromeDir <- System.AppContext.BaseDirectory
start chrome
"test 1" &&& fun _ ->
...
"test 2" &&& fun _ ->
...
"test 3" &&& fun _ ->
...
[<EntryPoint>]
let main args =
run()
quit()
0
当我运行这个程序时:
dotnet run
所有三个测试都运行。
假设默认情况下,我想运行test 1
和test 2
。 但有时,我只想运行test 3
。
在 Canopy 中进行设置的推荐方法是什么?
像传递命令行选项这样的东西会很好:
dotnet run # Run the default tests
dotnet run -- test-3 # Run test 3
或者,我想我可以将test 3
放在一个单独的项目中。 但这似乎只是为了进行单独的测试而产生的大量开销。
感谢您的任何建议!
我认为没有任何内置方法可以做到这一点,但手动管理似乎很容易:
let defaultTests () =
"test 1" &&& fun _ -> ()
"test 2" &&& fun _ -> ()
let test3 () =
"test 3" &&& fun _ -> ()
[<EntryPoint>]
let main (args : _[]) =
let arg =
if args.Length = 0 then "default"
else args.[0]
match arg with
| "default" -> defaultTests ()
| "test-3" -> test3 ()
| _ -> failwith $"Unknown arg: {arg}"
run()
quit()
0
诀窍是确保只有您想要运行的测试在运行时才真正得到定义。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.