vendredi 26 février 2016

How do I mock this protected method and return an Object using Jmockit?

I have the following method in class DummyClass :

protected Response prepareResponse(String Id, BigInteger version, String Reason, boolean isSuccessful,
        String errorCode, String errorMessage)

Inside the method, I am setting all the parameters in the arguments to the Response and returning it. But I wonder how to mock the method using Jmockit.

So far, I used the following approach :

      new MockUp<DummyClass>() {
          @Mock protected Response prepareResponse(String Id, BigInteger version, String Reason, boolean isSuccessful,
                    String errorCode, String errorMessage){
                        // I am not sure what to return here. I have to set the fields and return the response object. But I am not sure how to do it.

          }
    };

I am stuck until here. Please let me know.

Thanks, Gautham

Aucun commentaire:

Enregistrer un commentaire