Hi Bill,
We just recently upgraded to ScalaTest 2.0 and I'm loving all the improvements.
That said, when I first started looking at FutureConcept/ScalaFutures I was a little disappointed. For one thing there didn't seem to be a way to test for failed futures - I didn't think of using the failed projection, that is clever. Please do add it to the documentation!
I was also disappointed because I had rolled my own "FutureResults" trait that looked a little different and I'm more used to that style. I tried to copy the style of OptionValues, where you can sort of extract the result of the Future inline when writing your assertions. They work with pimps and implicit conversions (much like OptionValues). For example,
val myFuture = Future.successful(7)
myFuture.success should equal(7)
val expectedException = new RuntimeException
val myFailure = Future.failure(expectedException)
myFailure.failure should equal(expectedException) // or
evaluating (myFailure.throwFailure) should produce[RuntimeException]
I also made some BeMatchers if all you want to do is verify that a future succeeds or fails and don't care about its value. This is particularly useful when dealing with unit futures:
val myUnitFuture: Future[Unit] = ...
myUnitFuture should be(success)
If I understand how to use ScalaFutures correctly the equivalent would be:
whenReady(myUnitFuture) { s => s should be(()) }
or maybe just an empty body for whenReady? Either way I think the BeMatcher version reads better.
Also, in all of these cases I have pretty nice descriptive failure messages, e.g. for myFailure.failure if you actually get a success, the failure message is something like "Expected future failure, but got success with value: XXX". Using ScalaFutures with the failed projection I got "The future returned an exception of type: java.util.NoSuchElementException, with message: Future.failed not completed with a throwable.."
Anyhow, I am very glad to see the Future support in ScalaTest, which does definitely have some big improvements over my own handrolled stuff - I was using Await rather than polling, for one thing. And I'm sure that I'll get used to the different style. Sorry I did not look at what was coming sooner - I would have definitely suggested the BeMatchers, at least.
Thanks,
Ryan