Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I have introduced a method that works for the time being. I would like to see Play introduce the concept of separate "Test" vs "IntegrationTest" scopes in sbt.</p> <p>I could go into Play and see how they build their project and settings in sbt and try to get IntegrationTest scope to work. Right now, I spent too much time trying to get it functioning.</p> <p>What I did was to create a Specs Around Scope class that gives me the ability to enforce a singleton instance of a TestServer. Anything that uses the class will attempt to start the test server, if it is already running, it won't be restarted.</p> <p>It appears as though Play and SBT do a good job of making sure the server is shut down when the test ends, which works so far.</p> <p>Here is the sample code. Still hoping for some more feedback.</p> <pre><code>class WithTestServer(val app: FakeApplication = FakeApplication(), val port: Int = Helpers.testServerPort) extends Around with Scope { implicit def implicitApp = app implicit def implicitPort: Port = port synchronized { if ( !WithTestServer.isRunning ) { WithTestServer.start(app, port) } } // Implements around an example override def around[T: AsResult](t: =&gt; T): org.specs2.execute.Result = { println("Running test with test server===================") AsResult(t) } } object WithTestServer { var singletonTestServer: TestServer = null var isRunning = false def start(app: FakeApplication = FakeApplication(), port: Int = Helpers.testServerPort) = { implicit def implicitApp = app implicit def implicitPort: Port = port singletonTestServer = TestServer(port, app) singletonTestServer.start() isRunning = true } } </code></pre> <p>To take this a step further, I simply setup two folders (packages) in the play/test folder: - test/unit (test.unit package) - test/integration (test.integration pacakage)</p> <p>Now, when I run from my Jenkins server, I can run:</p> <blockquote> <p>play test-only test.unit.*Spec</p> </blockquote> <p>That will execute all unit tests.</p> <p>To run my integration tests, I run:</p> <blockquote> <p>play test-only test.integration.*Spec</p> </blockquote> <p>That's it. This works for me for the time being until Play adds Integration Test as a lifecycle step.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload