EarlGrey icon indicating copy to clipboard operation
EarlGrey copied to clipboard

Refactor: Reimplement 6 matchers and remove dependency on OCHamcrest

Open axi0mX opened this issue 9 years ago • 9 comments
trafficstars

Refactoring. It seems that EarlGrey doesn't really need OCHamcrest framework and the dependency could be removed after reimplementing only 6 matchers.

  1. Reimplement 6 matchers
  2. Remove OCHamcrest-related code

Is this something you want to do? I realize some of these changes may not be compatible with the internal version of EarlGrey. If you want to accept some parts of this PR, but not everything, I can undo whatever changes you don't want to merge.

Positive impact:

  1. Once fishhook is removed, EarlGrey has 0 dependencies on non-Apple code
  2. Net removal of 200+ lines of code
  3. Once fishhook is removed, no need to run Scripts/setup-earlgrey.sh (only required for OCMock for unit tests)
  4. No need to read OCHamcrest code to understand how 5 GREYMatchers work and what they do
  5. Mismatch description is now consistent with other GREYMatchers

axi0mX avatar Jul 30 '16 03:07 axi0mX

Thanks for the corrections here!! While having an external dependency can be painful, OCHamcrest does have a very rich set of matchers that would simply be duplicated in our code if we remove the dependency.

tirodkar avatar Jul 30 '16 03:07 tirodkar

OCHamcrest does have a very rich set of matchers that would simply be duplicated in our code if we remove the dependency.

It looks like we're only using 6 of them though?

bootstraponline avatar Aug 01 '16 14:08 bootstraponline

It looks like we're only using 6 of them though?

That's only in our test project. Currently, with GREYHCMatcher, a user can use all of the matchers provided by OCHamcrest - https://github.com/hamcrest/OCHamcrest#predefined-matchers

tirodkar avatar Aug 01 '16 21:08 tirodkar

Currently, with GREYHCMatcher, a user can use all of the matchers provided by OCHamcrest

Oh. I didn't realize that. Very cool.

bootstraponline avatar Aug 01 '16 21:08 bootstraponline

@tirodkar Read the code in this PR. These 6 matchers are not in the test project. It's inside EarlGrey, and see just how much duplication there is when you rewrite them, and how much code you can remove.

Actually, EarlGrey users cannot use them. OCHamcrest is not exposed by EarlGrey, and neither is GREYHCMatcher header.

axi0mX avatar Aug 01 '16 22:08 axi0mX

@tirodkar Read the code in this PR. These 6 matchers are not in the test project. It's inside EarlGrey, and see just how much duplication there is when you rewrite them, and how much code you can remove.

We added these particular matchers and bridged them in because we were using them internally in our tests. That's what I meant by test project :)

OCHamcrest is not exposed by EarlGrey, and neither is GREYHCMatcher header.

Ah, we could actually expose it. Thanks for bringing this to our attention.

tirodkar avatar Aug 01 '16 22:08 tirodkar

I don't think exposing them is a good idea. We should remove it. That's why I made this PR. Anything we need is easily reimplemented, will be more consistent with other EarlGrey matchers and gives us the ultimate flexibility for fixing and changing things.

axi0mX avatar Aug 01 '16 23:08 axi0mX

I think Espresso allows using arbitrary hamcrest matchers. If removing them prevents end users from matching with OCHamcrest then that doesn't seem great.

I don't see a lot of value in reimplementing all the OCHamcrest matchers.

bootstraponline avatar Aug 01 '16 23:08 bootstraponline

@tirodkar Can we find out how many users will impacted by this change? If there's not a lot, I am in favor of removing this dependency.

khandpur avatar Feb 10 '17 23:02 khandpur