Scalatra offers a DSL to write tests. There is support for specs2 and scalatest.
By default an embedded Jetty will be used for testing. If you want to provide your own server, you can reuse the EmbeddedJettyContainer
implementation and override start
, stop
and servletContextHandler
.
start
will be called before executing the tests, which allows to start your server if required. stop
is called after the tests. servletContextHandler
is required in order to add your servlets using addServlet(..)
.
This is from the spec2 integration:
trait BaseScalatraSpec extends SpecificationStructure with FragmentsBuilder with ScalatraTests {
override def map(fs: =>Fragments) = Step(start()) ^ super.map(fs) ^ Step(stop())
}
trait ScalatraTests extends EmbeddedJettyContainer with HttpComponentsClient { }
Alternatively you can provide your own Container implementation.