title: Why is Future not returned from actor to ScalaTest's whenReady?
body: <p>I am having an issue with a <code>Future</code> that is not returned from an actor in a ScalaTest case using <code>whenReady</code>. </p>
  
  <p>Here is the test case</p>
  
  <pre class="lang-scala prettyprint-override"><code>"A PolicyHolderDAO Actor" must { 
    "return a failure if given a policy holder to update without an id" in { 
      val updatePolicyHolderFailureAny : Future[Any] = policyHolderDAOActor ? PoliHolderDAO.Update(Future(policyHolder))
      val updatePolicyHolderFailure : Future[PolicyHolderDAO.Failure] = updatePolicyHolderFailureAny.mapTo[PolicyHolderDAO.Failure]
      whenReady(updatePolicyHolderFailure, timeout(5 seconds), interval(5 millis)) { failure =&gt; 
        failure.error.getMessage must be ("When updating a policy holder, we must have an id")
      }
    }
  }
  </code></pre>
  
  <p>Here is the <code>receive</code> method of the actor: </p>
  
  <pre><code>override def receive = {
    case PolicyHolderDAO.Update(policyHolder) =&gt; 
      val s = sender
      policyHolder map { p =&gt;
        p match {
          case _ if p.id.isDefined =&gt; s ! update(policyHolder)
          case _  =&gt; println("HERE"); s ! PolicyHolderDAO.Failure(throw new IllegalArgumentException("When updating a policy holder, we must have an id"), None)
        }
      }
  }
  </code></pre>
  
  <p>The <code>Update</code> case class is as follows </p>
  
  <pre><code>case class Update(policyHolder : Future[PolicyHolder]
  </code></pre>
  
  <p>What I am trying to do is to check to see if the policy holder has an <code>id</code>. If it has an <code>id</code>, pass it on to the <code>update</code> method, if it does not have an <code>id</code>, return a failure. The happy path works fine, and the sad path seems to work fine as well, by that I mean <code>println("HERE")</code> is executed. However my test case seems to not receive a reply from the actor in the sad path scenario. </p>
  
  <p>Here is the error message </p>
  
  <pre><code>[info] A PolicyHolderDAO Actor
  HERE
  [info] - must return a failure if given a policy holder to update without an id *** FAILED ***
  [info]   A timeout occurred waiting for a future to complete. Queried 980 times, sleeping 5000000 nanoseconds between each query. (PolicyHolderDAOSystemTest.scala:103)
  </code></pre>