dart-lang / mockito

Mockito-inspired mock library for Dart
https://pub.dev/packages/mockito
Apache License 2.0
623 stars 160 forks source link

Verify constructor #714

Open fernando-s97 opened 8 months ago

fernando-s97 commented 8 months ago

I have a class A that has a method b().

The method B creates the object C with some specific args and execute the d() method.

So A().b() calls C(specific args).d().

The signature of B and D methods are the same. A only exists to create C with those specifics Args. So it's kind of a proxy in order to be aligned to DRY and not call C(specific args) multiple times in different places + be more semantic. B is a generic name and D is a better name for my specific use case.

I already have all the tests written for A and B, but since C.d is a proxy to A.b that only specifies custom logic to the constructor, I don't want to retest everything again. I only want to make sure C was called with the correct arguments.

How could I do this?

srawlins commented 8 months ago

Thanks for the question! There are very few developers who work on this package (you can count them on one hand), so we recommend asking questions like this on a user forum with more people available to answer, such as StackOverflow.