且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

PowerMockito模拟单个静态方法并在另一个静态方法中返回对象

更新时间:2023-11-22 13:59:22

我在某人的在我的情况下,我使用了PowerMockito的部分模拟,如下所示.

In my case, I have used same partial mock of PowerMockito as below.

PowerMockito.stub(PowerMockito.method(OpenPgpUtility.class, "readPublicKey", InputStream.class)).toReturn(mockPGPPublicKey);

这让我可以模拟readPublicKey(),但实际上是对encrypt()

which letting me to mock readPublicKey() but an actual call to encrypt()