我正在继续我的测试DSL的堆栈溢出驱动编程 - 感谢迄今为止所做的贡献!我可以从Scala中的非逗号分隔的一组令牌创建一个元组吗?
此刻我的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")
}
给出
,当再是采取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来说太远了?
我曾考虑使用|或者类似的东西,但是一切似乎至少和逗号一样突兀,因为需要更多的工作。 – 2011-06-10 11:57:03
通常“is”似乎在你的情况下工作得很好:'然后([SignInPage]是“显示”)','和(“ErrorMessage”是“Sign in failed”) – Landei 2011-06-10 12:39:59