Unit testing Lagom services
In this section, you will learn how to unit test Lagom Framework's microservices, using Akka Toolkit's Testing modules.
Lagom Framework provides the following two testing modules to unit test our Reactive microservices or Reactive web applications:
lagom-core-testkit
lagom-scaladsl-testkit
We will refer to the lagom-scala-hello-service
project available under this chapter folder in the GitHub repository.
Perform the following steps to unit test the lagom-scala-hello-service
components:
- Add the following SBT plugin to the
/project/plugins.sbt
file:
addSbtPlugin("com.lightbend.lagom" % "lagom-sbt-plugin" % "1.4.0-M3")
The preceding Lagom's SBT plugin pulls not only the required Lagom libraries to develop a Reactive microservice, but also pulls the two previously mentioned Testing Module libraries, then set to our project's classpath.
- Write a unit test to test our Hello Entity, as shown here:
class LagomscalahelloserviceEntitySpec extends WordSpec with ...