It relied on the deprecated service-manager.
Instead, service-manager-2 should be started with an appropriate PROFILE before running the integration tests.
service-integration-test is a Scala library providing some useful functionality for integration tests.
The library starts all your dependencies using smserver and then runs the tests.
Include the following dependency in your SBT build
resolvers += Resolver.bintrayRepo("hmrc", "releases")
libraryDependencies += "uk.gov.hmrc" %% "service-integration-test" % "x.x.x" % "test,it"
In your scalatest Spec extend from ServiceSpec
and provide a list of external services you need smserver to start.
In this example, a call is made to the /example/hello-world endpoint on the tested microservice.
This service has a dependency to a-microservice
that is started on beforeAll and stopped on afterAll:
import org.scalatest.{Matchers, WordSpec}
import play.api.libs.ws.WSClient
import uk.gov.hmrc.integration.ServiceSpec
class ExampleIntegrationTest extends WordSpec with Matchers with ServiceSpec {
def externalServices: Seq[String] = Seq("a-microservice")
"This integration test" should {
"start a-microservice via smserver" in {
val wsClient = app.injector.instanceOf[WSClient]
val response = wsClient.url(resource("/example/hello-world")).get.futureValue
response.status shouldBe 200
}
}
}
Run service-manager
smserver
Then run tests.
- Drops Play 2.6 and 2.7 support - only supports Play 2.8
- Cross builds for Scala 2.12 and 2.13
Run mode prefix is dropped from microservice.services.
configuration - it is expected that your services do not require the run mode prefix anymore.
Mongodb uri is now configured with mongodb.uri
(previously ${runModePrefix}microservice.mongodb.uri
).
The mongodb uri is configured with serviceMongoUri
. The default is generated to avoid conflicts, and should suffice; but if you are combining the ServiceSpec
with a mongo test trait, then you will need to synchronise the two. E.g.
class ExampleIntegrationTest extends WordSpec with Matchers with ServiceSpec with MongoSupport {
override def mongoUri = super.serviceMongoUri
// alternatively
//override def serviceMongoUri = super.mongoUri
}
This code is open source software licensed under the Apache 2.0 License.