Feature: Add a way to verify constructor is called with defined values
See original GitHub issuePrerequisites
Please answer the following questions for yourself before submitting an issue.
- I am running the latest version
- I checked the documentation and found no answer
- 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"))
Issue Analytics
- State:
- Created 2 years ago
- Reactions:15
- Comments:5
Top Results From Across the Web
Mockito: how to test that a constructor was called?
You can do it with Mockito and PowerMockito. Say you have ClassUnderTest with a constructor public class ClassUnderTest { String name; boolean condition; ......
Read more >Mock constructor calls with Mockito - David Vlijmincx
Use mockito to mock calls made to the constructor and return a mock. ... We can add a dependency or create a file...
Read more >Mock Java Constructors With Mockito | Configuration ... - rieckpil
Learn how to mock Java constructors to return mock objects using Mockito (with version >= 3.5.0) and the InlineMockMaker.
Read more >Mockito 3.5.0 API - javadoc.io
Once stubbed, the method will always return a stubbed value, regardless of how many times it is called. Last stubbing is more important...
Read more >Constructors in Java - GeeksforGeeks
A constructor that has parameters is known as parameterized constructor. If we want to initialize fields of the class with our own values,...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
That one would be nice!
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 animportant
label.