How to Test a Play Application that extends a custom trait
<p>I'm having trouble writing tests for a mixin to my Play application that runs in it's own thread separate from play. I've tried over-writing <code>WithApplication.provideApplication</code> method with no luck. I get an <code>inheriting conflicting methods</code> error. (one from the real app "MyRunnableSystemWrapper", one from my <em>mocked</em> fake mixin called "MyMockedSystemWrapper"). </p>

<p><code>execute(system)</code> runs my system that is tested elsewhere and has sideaffects (connects to networked services, thus failing this test when such things are not available. Good news is I have a mocked service of my system wrapper that uses a system which does NOT have side affects and DB/Network calls are mocked out. However I do not know how to give THIS MOCKED version of my app to "WithApplication" test. </p>

<p>Reduced Code for clarity: </p>

<pre><code>class Application extends Controller with MyRunnableSystemWrapper {

  val pool: ExecutorService = Executors.newFixedThreadPool(1)
  val system = new MyRunnableSystem() //system is abstract in MRSW ^^^ above
  pool.execute(system)

  def index = Action {
    OK("HI")
  }
}
</code></pre>

<p>My Test: </p>

<pre><code>class MyAppTest(implicit ee: ExecutionEnv) extends Specification  {

  abstract class WithMyMockApp extends WithApplication {
    def provideApplication = new controllers.Application with MyMockedSystemWrapper // This imports MyRunnableSystemWrapper 

  }

  "Sending a GET request" should {
    "Respond with OK" in new WithMyMockApp {
      val response = route(app, FakeRequest(GET, "/")).get
      status(response) mustEqual OK
    }
  }
}
</code></pre>

<p>If I'm not running my Runnable in the correct place and should be calling it somewhere else to make this testing easier, let me know! </p>