如何使用PowerMock和Mockito模拟默认构造函数?

如何使用PowerMock和Mockito模拟默认构造函数?

问题描述:

我应该如何使用PowerMock-Mockito(No EasyMock)模拟默认构造函数?

How should I mock the default constructor using PowerMock-Mockito(No EasyMock) ?

我要这样做,以访问对象的值.

I want to access the values of the object by doing this.

例如:

Class A {

public A()
{
}

}

PowerMockito.whenNew API应该用于执行此操作.有关更多信息,请参见此链接:如何模拟新对象的构建

PowerMockito.whenNew API should be used to perform this. See this link for further information: How to mock construction of new objects