<p dir="auto">For the query refactoring we started testing equals()/hashCode() contracts for the query builders in a central abstract <a href="https://github.com/elastic/elasticsearch/blob/master/test/framework/src/main/java/org/elasticsearch/test/AbstractQueryTestCase.java#L725">base test</a>, assuming the test can use some helper methods to e.g. make deep copies of objects via serialization. We have similar tests e.g. in <code class="notranslate">BaseAggregationTestCase</code> and for several other parts of the search request (e.g. the SuggestBuilderTests via the abstract WritableTestCase, AbstractShapeBuilderTestCase). We also started doing those kind of tests in a helper class now in the rank_eval module, which triggered the <a href="https://github.com/elastic/elasticsearch/pull/20497#discussion_r79830341" data-hovercard-type="pull_request" data-hovercard-url="/elastic/elasticsearch/pull/20497/hovercard">discussion</a> if we should make an effort to centralize this.</p>
<p dir="auto">While putting this kind of basic equals/hashCode tests into abstract superclasses works for test of similar classes (e.g. all queries), it is a bit tricky to generalize this easily and makes the test inheritance structure hard and tests sometimes difficult to read. On the other hand, having this kind of tests clearly documented in some central test utility class would make reusing it more straight forward and avoid the duplication we have today. I'm leaning towards not inheriting this kind of testing code but rather have some utility function somewhere that e.g. takes the original object, some function that returns a deep copy and a function that returns a mutation (an instance different in only one aspect) as arguments and does all the assertions necessary. This way it can be used by different tests without the burden of having to inherit various levels of abstract base test classes.</p>
<p dir="auto">Please, see <a href="https://discuss.elastic.co/t/phrase-highlighting-works-incorrectly-on-es-2-1-1-and-2-2-0/39971" rel="nofollow">https://discuss.elastic.co/t/phrase-highlighting-works-incorrectly-on-es-2-1-1-and-2-2-0/39971</a></p>