In the following, I am using the Play2 ReactiveMongo plugin in version 0.11.0.play24 (http://ift.tt/1nuRCGW) for Play 2.4.
As mentioned in the documentation located at http://ift.tt/1J2LZ8f, a Play2 controller with Mongo is instantiated as follows:
class MyController @Inject() (val reactiveMongoApi: ReactiveMongoApi)
extends Controller with MongoController with ReactiveMongoComponents { }
Therefore, since the controller is now a class and not an object, it is not possible to use it as a singleton in the test cases.
However, I do not know how to inject the reactiveMongoApi in order to instantiate a MyController() with the right parameters in a test case (ScalaCheck or other...)
Do you have any idea/example on how to test such a controller with ScalaCheck or Specs2?
Thank you in advance!
Aucun commentaire:
Enregistrer un commentaire