New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implemented mocking constructors with parameters #583
Conversation
Codecov Report
@@ Coverage Diff @@
## master #583 +/- ##
============================================
+ Coverage 75.57% 75.89% +0.31%
- Complexity 816 817 +1
============================================
Files 100 100
Lines 2788 2825 +37
Branches 435 445 +10
============================================
+ Hits 2107 2144 +37
Misses 502 502
Partials 179 179
Continue to review full report at Codecov.
|
This takes over from @oleksiyp 's implementation in #267 to provide a working implementation of #209.
The main difference with the original implementation is fixing a bug with handler matching that prevented calls like
from working.
Basically, the handlers map in ConstructorMockVariety was using an Array as the key, and comparing arrays compares their references rather than comparing their content.
This means that getting an existing handler was always failing, because the
equals
call between argument arrays was always returning false: this in turn meant that verification was failing because when retrieving the mock to run verification against the retrieval failed and the verification was being run against a "clean" mock, with no recorded calls.By using a List rather than an array, retrieving existing mocks works as expected and verification is performed against the proper mock.