Reputation: 521
I'm using ScalaTest's Eventually.eventually
and have configured it so that it tries to get a record every second until the status is complete:
Eventually.eventually(timeout(5 seconds), interval(1 seconds)) {
getItem(recordId).record.forall(
_.state.contains(Constants.RecordStatusComplete)) shouldEqual true
}
I must get the number of times getItem(recordId)
was called. How can I do that?
Upvotes: 1
Views: 508
Reputation: 1293
How about just counting it? A bit ugly maybe but scalatest doesn't seem to provide you the amount of attempts it made and presumably this is for testing only, so:
val count = Iterator from 0
Eventually.eventually(timeout(5 seconds), interval(1 seconds)) {
count.next()
getItem(recordId).record.forall(
_.state.contains(Constants.RecordStatusComplete)) shouldEqual true
}
// count.next() will give you the attempts
I could think of other solutions using mocking frameworks etc. but they'll probably turn out fairly similar.
Upvotes: 1