title: Testing Akka with Specs2
body: <p>I have the following specs2 test:</p>
  
  <pre><code>package concurrent
  
  import akka.actor.{Props, actorRef2Scala}
  import akka.testkit.TestActorRef
  
  import scala.concurrent.duration._
  
  class MessageCoordinatingActorSpec extends ActorBaseSpec {
  
    "MessageCoordinatingActor" should {
      "receive a Result and update the related token and status" in {
        val (repositoryActorProbe, messageCoordinatingActorRef) = buildMockMessageCoordinatingActor
  
  
        val addresses = MockSession.getTestAddressesWithServicesAt(
                                     "16 Main Street", List("Service1", "Service2"))
        val postCode = Postcode("NE28 9QR", addresses)
  
        val matchedAddr = addresses.find(_.addrToken=="16 Main Street")
  
  
        messageCoordinatingActorRef ! Result(LookupResult(
          LookupStatus.ServicesAvailable, postCode, matchedAddr, true), testRecord)
  
        //Expect message to persist the virgin postcode record
        repositoryActorProbe.expectMsg(pairLongToDuration(3, SECONDS),
          PersistPostcode(postCode))
  
        1 mustEqual 1
      }
    }
  }
  
  abstract class ActorBaseSpec extends TestKit(ActorSystem("test")) with ImplicitSender with MustMatchers with SpecificationLike with Mockito {
      //This class just contains some fixture factory methods 
      //such as buildMockMessageCoordinatingActor
  }
  </code></pre>
  
  <p>The content of the test is pretty unimportant to my question, but i have two problems. Firstly  notice i had to use </p>
  
  <pre><code>pairLongToDuration(3, SECONDS)
  </code></pre>
  
  <p>I want to be able to use </p>
  
  <pre><code>3.seconds (from the scala.concurrent.duration package)
  </code></pre>
  
  <p>but when i do, i get the following error:</p>
  
  <pre><code>[error]  found   : org.specs2.time.Duration
  [error]  required: scala.concurrent.duration.FiniteDuration
  </code></pre>
  
  <p>Any idea how i can get around this?</p>
  
  <p>Also notice i had to stick </p>
  
  <pre><code>1 mustEqual 1
  </code></pre>
  
  <p>at the bottom. If i take this out i get</p>
  
  <pre><code>[error] /Users/.../MessageCoordinatingActorSpec.scala:18: could not find implicit value for evidence parameter of type org.specs2.execute.AsResult[concurrent.RepositoryActor.UpdateAddrToken]
  </code></pre>
  
  <p>It seems that specs2 does not recognise the probe.expectMsg success as being a test success, is there any way to fix this in a more satisfactory way?</p>
  
  <p>Cheers!
  NFV</p>