So, according to the Play 2.4 documentation ( https://playframework.com/documentation/2.4.x/ScalaTestingWithScalaTest#Unit-Testing-Controllers ), the controller should be configured as a trait like this
trait ExampleController { this: Controller => def index() = Action { Ok("ok") } } object ExampleController extends Controller with ExampleController
so that the test works this way
class ExampleControllerSpec extends PlaySpec with Results { class TestController() extends Controller with ExampleController "Example Page#index" should { "should be valid" in { //test code } } }
however, I am using Guice dependency injection, and according to the Play 2.4 documentation ( https://playframework.com/documentation/2.4.x/ScalaDependencyInjection ) my controller looks like this:
@Singleton class ExampleController @Inject() (exampleService: IExampleService) extends Controller { def index() = Action { Ok("") } }
Since the controller is no longer a sign, and I can not mix it with the test as follows: with ExampleController , how do I make the test higher?
source share