document Specs2 + TestKit, see #2068, plus fix up broken includes
- include move of doc samples out of akka package also in the includecode directives - fix broken serialization docs, which require one thing in the akka package
This commit is contained in:
parent
7d342e5c96
commit
dd30e81a1a
44 changed files with 681 additions and 555 deletions
34
akka-docs/scala/code/docs/testkit/Specs2DemoSpec.scala
Normal file
34
akka-docs/scala/code/docs/testkit/Specs2DemoSpec.scala
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
package docs.testkit
|
||||
|
||||
import org.specs2.mutable.Specification
|
||||
import org.specs2.specification.Scope
|
||||
|
||||
import akka.actor.{ Props, ActorSystem, Actor }
|
||||
import akka.testkit.{ TestKit, ImplicitSender }
|
||||
|
||||
class Specs2DemoUnitSpec extends Specification {
|
||||
|
||||
val system = ActorSystem()
|
||||
|
||||
implicit def d2d(d: org.specs2.time.Duration): akka.util.FiniteDuration =
|
||||
akka.util.Duration(d.inMilliseconds, "millis")
|
||||
|
||||
/*
|
||||
* this is needed if different test cases would clash when run concurrently,
|
||||
* e.g. when creating specifically named top-level actors
|
||||
*/
|
||||
sequential
|
||||
|
||||
"A TestKit" should {
|
||||
"work properly with Specs2 unit tests" in
|
||||
new TestKit(system) with Scope with ImplicitSender {
|
||||
within(1 second) {
|
||||
system.actorOf(Props(new Actor {
|
||||
def receive = { case x ⇒ sender ! x }
|
||||
})) ! "hallo"
|
||||
|
||||
expectMsgType[String] must be equalTo "hallo"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue