In this section, we will discuss how to unit test Play Framework components, using ScalaTest and its associated ScalaTest Plus unit testing frameworks.
Unit testing Play Framework components
Test HelloWorld without using DI Controller
In this section, we are going to refer play-scala-helloworld-app Play Scala-based HelloWorld application available in the Chapter-6 folder from the GitHub repository (https://github.com/rposa-srp-book/srp-book-examples/tree/master/Chapter-6/play-scala-helloworld-app) and write unit tests for its controller.
Perform the following steps to write unit tests for this application:
- Add the following entry in the build.sbt file available in the root folder of this project:
libraryDependencies...