-
Notifications
You must be signed in to change notification settings - Fork 21
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
Implement AssertAll
#248
Implement AssertAll
#248
Conversation
- Extract interface from `Assertion` - Add `AssertAll` - Add `AssertWith` - Add OO-Envelope for assertions
Codecov Report
@@ Coverage Diff @@
## master #248 +/- ##
============================================
+ Coverage 99.05% 99.15% +0.09%
- Complexity 165 184 +19
============================================
Files 36 40 +4
Lines 425 471 +46
Branches 8 8
============================================
+ Hits 421 467 +46
Misses 4 4
Continue to review full report at Codecov.
|
@andreoss hey, thanks for the effort. I have to say I'm not sure I would like to introduce those changes to the codebase, there a few things that worries me, let me share them with you, maybe this could change my mind:
All in all, I think we are missing two important pieces here for this PR to be seriously considered:
I hope it's not too much disappointing, but I'm open to discussion to improve cactoos-matchers :) Also, I have been working on improving the architecture as I started to outline it in that comment: #239 (comment) (i.e., introducing our own interface to replace Matcher), maybe the requirements that your PR is trying to solve could be covered by the solution we found there? |
That's not the case, |
@0crat status |
@victornoel Some closing remarks
I still believe we should have multiple ways to write an assertion, instead of one |
Job |
@andreoss thx for writing down a summary of your findings on that matter. I completely agree with some of the problems you identify, mainly Matcher's being somewhat unfit to match cactoos' OO approach. On this, I started experimenting on introducing an alternative interface to Matcher that is simpler to implement and reason about. In that vision, Assertion would take such an object instead of Matcher. And we would provide an implementation of that interface taking Matcher's object for compatibility. I will create a ticket and/or a PR for discussing it, I hope you will share your feedbacks on it! Also one problem with Matcher's implementations, e.g., AllOf that you cite, is that they were not meant to be used directly via their constructor but via static methods and so their constructor usage is sometimes cumbersome. This is just a technical limitation that can be solved via improved constructors. In the case of this new alternative interface it means we should be able to implement a nice to use AllOf-type of implementation. Concerning Assertion being an interface, I don't see it as a problem actually, it's just that until now, I haven't seen any good reason to go down that path and thus I'm pushing making such a decision for as late as possible. It's a mix of laziness and carefulness let's say: I would prefer to have a clear use case for it and haven't seen it yet (except in this PR, which is a good start, but as-is as discussed, we won't be merging it). The next paragraph outline a way to do so :) Concerning the tooling on executing tests (test object), while I like the approach, I don't think that this is what cactoos-matchers is about, at least for now: it should be an alternative to using Assertion, but this choice is for the user, not for us to make, so I don't think making it the only way of implementing tests is correct. So, to open the door for going that way, I would propose to create a new ticket for a proposal of design to add to cactoos-matchers on top of its existing components, if you would like to. This could rely on the fact Assertion must be an interface of course. |
Per #156
Extract interface from
Assertion
Implement
AssertAll
&AssertWith
Introduce matchers
Fails
&Passes
Refactor tests