【发布时间】:2011-06-10 19:49:57
【问题描述】:
我正在继续我的 Stack-Overflow-Driven 测试 DSL 编程 - 感谢所有迄今为止做出贡献的人!
目前我的 DSL 是这样的
scenario("Incorrect password") {
given("user visits", the[AdminHomePage])
then(the[SignInPage], "is displayed")
when("username", "admin", "and password", "wrongpassword", "are entered")
then(the[SignInPage], "is displayed")
and("Error message is", "Sign in failed")
}
给定,when 和 then 是采用 Any 的方法,因此当像这样调用它们时,它们会传递一个参数元组 - Why and how is Scala treating a tuple specially when calling a one arg function?。
理想情况下,我会去掉逗号,这样读起来会更好,只有空格分隔标记
scenario("Incorrect password") {
given("user visits" the[AdminHomePage])
then(the[SignInPage] "is displayed")
when("username" "admin" "and password" "wrongpassword" "are entered")
then(the[SignInPage] "is displayed")
and("Error message is" "Sign in failed")
}
谁能想到任何可以让我实现这个目标的技术,还是对于内部 DSL 来说太过分了?
【问题讨论】: