vendredi 5 février 2016

Can't find a private method exception, while testing a private method

I am trying to write the unit test case for my private method in scala using MockitoSugar but it is throwing Can't find a private method exception. Here is my code.

      object ActivityRepo{

        private def addActivity(activity:Activity):Future[Activity]={
              //doing DB calls
          }
      }

Unit test:

      "Activity Repo Test" must {

        "add Activity" in {
          // doing mock for the DB calls

          val addActivity = PrivateMethod[Future[Activity]]('addActivity)

          val result = ActivityRepo invokePrivate addActivity (activity)
          // doing assertions      
         }
      }

Please help me to find out the mistake. Thanks in advance.

Aucun commentaire:

Enregistrer un commentaire