我使用PlayFramework 2.3和specs2来编写功能测试。
在文档中,有以下示例
"run in a browser" in new WithBrowser(webDriver = WebDriverFactory(HTMLUNIT), app = fakeApplicationWithBrowser) {
…
}
如何针对多个驱动程序运行此测试?
我目前使用:
def drivers: Seq[String => WebDriver] = ...
examplesBlock {
for (driver <- drivers) {
"run in a browser" in ((s: String) => new WithBrowser(d(s)) {
…
}
}
}
有更好(更简单)的方法吗?
答案 0 :(得分:0)
最后,通过提取trait
trait MultiBrowser {
self : Specification =>
def drivers : Seq[String => WebDriver]
def browsers(u: (String => WebDriver) => Unit) = examplesBlock {
for (driver <- drivers) {
u(driver)
}
}
}