如何模拟此受保护的方法并使用Jmockit返回Object?

时间:2016-02-26 21:06:38

标签: java unit-testing junit mocking jmockit

我在DummyClass类中有以下方法:

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

在方法内部,我将参数的所有参数设置为Response并返回它。但我想知道如何使用Jmockit模拟该方法。

到目前为止,我使用了以下方法:

      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.

          }
    };

我被困在这里。请告诉我。

谢谢, Gautham

0 个答案:

没有答案