鉴于类似的代码:Specs2和@前/ @之后,类似的方法
class RESTAcceptanceTest extends Specification {
override def is = anonymous^signinOAuth
def anonymous = "Something" ^givenSomething^
"must happen" ^mustHappen
end
def signinOAuth = "Signin" ^givenSignin^
"works as expected" ^userExistsInDatabase
end
// rest of object definitions
}
我怎么保证之前,执行代码之后同前/ 后“匿名” 和“signinOAuth” ,即使测试本身失败,“after”方法应该执行 ?
谢谢!我几乎这样做,但没有找到如何处理上下文。我希望用这个例子更新Specs2用户指南。 – jdevelop
我已经更新了文档,但也启用了使用'BeforeExample','AfterExample',...特征与给定/当/然后步骤(1.12.4-SNAPSHOT for Scala 2.9.2和1.13.1-SNAPSHOT对于Scala 2.10)。请参阅文档:http://etorreborre.github.com/specs2/guide-SNAPSHOT/guide/org.specs2.guide.Structure.html#Contexts。 – Eric