scalamock and async verification of stubs (with specs2)

149 views
Skip to first unread message

Toby Weston

unread,
Jun 18, 2015, 7:16:52 AM6/18/15
to specs2...@googlegroups.com

Just wondered if anyone saw this on SO and had any comments?

Scalamock suggest posting on SO but I've had no bites, apologies for cross posting but its tumble weed on stackoverflow.

I'm basically wondering if theres a way to hook in a retry type thing in a verification stage on a Specification. It's related to running web driver (read async) tests and is complicated more as I'm using a scalamock stub in the 'verify' stage.

http://stackoverflow.com/questions/30798833/scalamock-and-async-verification-of-stubs-with-specs2

Thanks,
Toby

etorreborre

unread,
Jun 18, 2015, 9:45:11 AM6/18/15
to specs2...@googlegroups.com, toby....@gmail.com
Hi again Toby,

I have no experience with ScalaMock nor how it integrates with specs2. However there are a few things you can do to evaluate results several times or asynchronously:

If you are dealing with Futures you can transform any Matcher[T] into a Matcher[Future[T]], see here (on the "Futures" tab) for the documentation.

On the same page you will also see that you can use the `eventually` method to retry a given matcher a certain number of times (you can specify the duration in the meantime).

If you want to apply the same retry logic to all your spec you can mix-in the AroundExample trait and implement it using the org.specs2.execute.EventuallyResults to systematically retry everything.

I'll cook up an example for you if you can't get it to work.

Eric.

Toby Weston

unread,
Jun 22, 2015, 3:36:12 AM6/22/15
to specs2...@googlegroups.com
Great, thanks again.

I only just spotted 'eventually', it's just the ticket. I ended up avoiding scalamock and doing something simpler using 'eventually'

All the best
Toby
Reply all
Reply to author
Forward
0 new messages