An SBT plugin to start and stop service manager dependencies for integration test
It requires to have configured service-manager
in order to be able to use this plugin. You can find it how here
In your project/plugins.sbt
file:
resolvers += Resolver.url("hmrc-sbt-plugin-releases",
url("https://dl.bintray.com/hmrc/sbt-plugin-releases"))(Resolver.ivyStylePatterns)
addSbtPlugin("uk.gov.hmrc" % "sbt-service-manager" % "x.x.x")
where 'x.x.x' is the latest release as advertised above.
In your project/FrontendBuild.scala
or project/MicroserviceBuild.scala
after the line .settings(inConfig(TemplateItTest)(Defaults.itSettings): _*)
- Add list of services that are required to be started.
lazy val externalServices = List(
ExternalService(name = "SERVICE1", enableTestOnlyEndpoints = true, extraConfig = Map("key" -> "value"), runFrom = Source),
ExternalService(name = "SERVICE2", enableTestOnlyEndpoints = false, runFrom = Jar)
)
- Add the line
.settings(ServiceManagerPlugin.serviceManagerSettings)
- Add the line
.settings(itDependenciesList := externalServices)
The attributes of ExternalService
are:
- name: Name of the service defined in the
service-manager
configuration. - enableTestOnlyEndpoints: To enable the test only endpoints. Default value is
false
. - extraConfig: Extra configuration required for the service. Default value is
Map()
. - runFrom: Whether to run the service from 'Jar' or 'Source'. Default value is
Jar
.
Running sbt it:test
will start the dependencies configured before running the tests and stop them at then end.
Run sbt startItDependencies
will start the dependencies configured.
Run sbt stopItDependencies
will stop the dependencies configured.
Run sbt itDependenciesList
will show the dependencies configured.
This code is open source software licensed under the Apache 2.0 License.