question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

Prerequisites

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:open
  • Created 2 years ago
  • Reactions:15
  • Comments:5

github_iconTop GitHub Comments

4reactions
cmaiercommented, Mar 12, 2022

That one would be nice!

1reaction
stale[bot]commented, Jul 10, 2022

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found