Startup Tests

By default the Finatra embedded testing infrastructure sets the Guice to DEVELOPMENT for the object graph of the server or application under test. For purposes of testing we choose the trade-off of a fast start-up time for the embedded server at the expense of some runtime performance as classes are lazily loaded when accessed by the test features.

However, this also means that if you have mis-configured dependencies (e.g., you attempt to inject a type that the injector cannot construct because it does not have a no-arg constructor nor was it provided by a module) you may not run into this error during testing as dependencies are satisfied lazily by default.

As such, we recommend creating a simple test – a StartupTest to check that your service can start up and report itself as healthy. This checks the correctness of the object graph, catching errors that could otherwise cause the server to fail to start.


A StartupTest should mimic production as closely as possible.

For example:

import com.twitter.finatra.http.EmbeddedHttpServer
import com.twitter.inject.server.FeatureTest

class MyServiceStartupTest extends FeatureTest {
  val server = new EmbeddedHttpServer(
    stage = Stage.PRODUCTION,
    twitterServer = new SampleApiServer,
    flags = Map(
      "com.twitter.server.resolverMap" -> "some-thrift-service=nil!"

  test("SampleApiServer#startup") {


This works for EmbeddedHttpServer or EmbeddedThriftServer as #assertHealthy() is defined on the EmbeddedTwitterServer super class.