根据这份文件来验证通话顺序,我们需要:
val m1 = mock[List[String]]
val m2 = mock[List[String]]
m1.get(0)
m1.get(0)
m2.get(0)
here was one(m1).get(0) then one(m1).get(1)
用我的代码
...
val db = mock[Database]
"The code" should {
"Should do something" in {
val id = "id"
db.readUserByid(anyString) returns None
val rv = api.login(id)
there was one(db).readUserByid(id) then one(db).createUser(anyString)
}
}
...
我得到一个错误
值则不是org.specs2.matcher.MatchResult [Option [models.domain.user.User]]的成员
和警告
现在是保留字;不赞成将其用作标识符
我正在使用与此版本的Play捆绑在一起的Play框架2.2.0,Specs2,Mockito 1.9.5
您能否指出一个正确的文件,其中包含有关验证呼叫顺序的信息?
非常感谢你 :)
您需要使用 andThen
there was one(db).readUserByid(id) andThen one(db).createUser(anyString)
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句