ScalaTest: Assert exceptions in failed futures (non-blocking)

[*] I know this is probably a bit late, but ScalaTest provides this feature out of the box (I believe since version 2) by mixing in the ScalaFutures trait, or using it directly in your test functions. Behold! test(“some test”) { val f: Future[Something] = someObject.giveMeAFuture ScalaFutures.whenReady(f.failed) { e => e shouldBe a [SomeExceptionType] } … Read more

Doing something before or after all Scalatest tests

The intended way to do this is to use nested suites. Suite has a nestedSuites method that returns an IndexedSeq[Suite] (in 2.0, in 1.9.1 it was a List[Suite]). Suite also has a runNestedSuites method that is responsible for executing any nested suites. By default runNestedSuites calls nestedSuites, and on each returned Suite either invokes run … Read more

What’s the difference between ScalaTest and Scala Specs unit test frameworks?

Specs and ScalaTest are both good tools with happy users, but they differ in several ways. You will probably want to pick one as your main testing tool in Scala, but need not give up the other because you can use pieces of both. If you like ScalaTest’s FeatureSpec syntax and specs’ Mockito syntax, for … Read more