基于Scala Specs2的测试。
class MyTests {
trait Context {
...
}
"test number 1" should {
"render stuff amazingly" in new Context {
...validations...
}
}Specs2中是否实现了截图机制?在官方网站和这里都没有找到任何关于它的信息。如果可能的话,我很乐意学习如何实现它。
发布于 2014-12-15 09:32:07
specs2中没有屏幕截图功能。
您可以简单地使用如下所示的Around上下文:
trait Screenshot {
// take a screenshot and store it under the given path
def takeScreenshot(path: String): Unit = ???
}
trait AroundEach with Screenshot {
// return a unique path
def screenshotPath: String = ???
def around[R : AsResult](r: =>Result): Result = {
// execute the result
val result = AsResult(r)
if (!result.isSuccess) {
val screenshot = takeScreenshot(screenshotPath)
result.update(_+"\nScreenshot at"+screenshot)
} else result
}
} 您还可以扩展ExampleFactory,使用示例描述创建截图路径。请参阅用户指南中的here,如果有任何问题,请在邮件列表上发布消息。
https://stackoverflow.com/questions/27471629
复制相似问题