title: How to throw an exception when your method returns a Future in a test?
body: <p>So I have a method in <code>TokenService</code> called <code>useToken</code>:</p>
  <pre><code>def useToken(token: String): Future[T] = {
  // returns either an instance of T or throws a ServerException
  }
  </code></pre>
  <p>This is wrapped inside another class say <code>AuthService</code>:</p>
  <pre><code>def useTokenForAuth(token: String): Future[AuthTokenData] = {
    tokenService.useToken(token) 
  }
  </code></pre>
  <p>In my test, I'm mocking the <code>useToken</code> to throw an Exception like:</p>
  <pre><code>when(
    mockTokenService.useToken(&quot;fake-token&quot;)
  ).thenThrow(new ServerException)
  
  mockAuthService.useTokenForAuth(&quot;fake-token&quot;)
  </code></pre>
  <p>and <code>mockAuthService</code> does not throw an Exception. Could it be because the return type is a <code>Future</code>?</p>