EasyMock: Mock out a constructor call in java

前端 未结 4 1116
生来不讨喜
生来不讨喜 2021-01-05 03:11

I have a looked at similar questions on this board, but none of them answer my question. This sound strange, but is it possible to mock out a constructor call on the object

4条回答
  •  悲哀的现实
    2021-01-05 03:48

    you can do so with EasyMock 3.0 and above.

    Customer cust = createMockBuilder(Customer.class)
         .withConstructor(int.class)
         .withArgs(145)
         .addMockedMethod("someMethod")
         .createMock();
    

提交回复
热议问题