mockk icon indicating copy to clipboard operation
mockk copied to clipboard

Feature: Add a way to verify constructor is called with defined values

Open devilk10 opened this issue 4 years ago • 9 comments
trafficstars

Prerequisites

Please answer the following questions for yourself before submitting an issue.

  • [x] I am running the latest version
  • [x] I checked the documentation and found no answer
  • [x] I checked to make sure that this issue has not already been filed

Expected Behavior

We can mock constructor and verify if a method was called on that mock class, here But there is no way to verify if a Constructor was called with defined parameter

class MockCls(private val a: Int = 0) {}

mockkConstructor(MockCls::class)

verifyNew(constructedWith<MockCls>("2"))

devilk10 avatar Nov 03 '21 11:11 devilk10

This issue is different from 209

devilk10 avatar Nov 03 '21 11:11 devilk10

did it solved?

yanjiepeng avatar Nov 25 '21 09:11 yanjiepeng

That one would be nice!

cmaier avatar Mar 12 '22 14:03 cmaier

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. If you are sure that this issue is important and should not be marked as stale just ask to put an important label.

stale[bot] avatar Jul 10 '22 20:07 stale[bot]

Hi, I would also like this feature to be included in the library.

LKorso avatar Oct 20 '22 16:10 LKorso

This issue should have important label

Sti2nd avatar Aug 02 '23 12:08 Sti2nd

This issue should have important label

Agreed, something like mockito's mockConstruction would be great. There are many cases where we need to validate the arguments used to instantiate an object

victorhsr avatar Jan 14 '24 04:01 victorhsr