scala - How to verify a method is called N times exactly in specs2? -
in specs2, can verify invocation times of method by:
there one(user).getname there two(user).getname there three(user).getname but how check n times? i'm looking like:
there times(n, user).getname unlucky there no such api
if @ implementation of specs2 bindings mockito, you'll find like
def one[t <: anyref](mock: t)(implicit anorder: option[inorder] = inorder()): t = verify(mock, org.mockito.mockito.times(1))(anorder) so guess can define own times method, mimicking one:
def times[t <: anyref](n: int, mock: t)(implicit anorder: option[inorder] = inorder()): t = verify(mock, org.mockito.mockito.times(n))(anorder) or utilize mockito explicitly:
val mocker = new mockitomocker {} verify(user, org.mockito.mockito.times(42)).getname scala unit-testing specs2
No comments:
Post a Comment