solr icon indicating copy to clipboard operation
solr copied to clipboard

SOLR-16109: Updates SolrTestCaseJ4 ABC doc comparators to static

Open paulkiernan opened this issue 3 years ago • 5 comments

https://issues.apache.org/jira/browse/SOLR-16109

Description

I'd like to be able to simply compare two SolrInputDocuments in unit tests without absorbing all the overhead that comes with the JUnit test suite.

Solution

Converting the prototype of the following methods to include the static modifier transforms them into functions I can use to this end:

  • compareSolrDocument
  • compareSolrDocumentList
  • compareSolrInputDocument
  • assertSolrInputFieldEquals

Tests

Applying this patch to a local solr repo, building the jar locally (after running gradlew check), and including that jar in the library dependencies of my project verify that the static comparators work as expected.

Checklist

Please review the following and check all that apply:

  • [x] I have reviewed the guidelines for How to Contribute and my code conforms to the standards described there to the best of my ability.
  • [x] I have created a Jira issue and added the issue ID to my pull request title.
  • [x] I have given Solr maintainers access to contribute to my PR branch. (optional but recommended)
  • [x] I have developed this patch against the main branch.
  • [x] I have run ./gradlew check.
  • [ ] I have added tests for my changes.
  • [ ] I have added documentation for the Reference Guide

paulkiernan avatar Mar 23 '22 08:03 paulkiernan

I'm not the Java-head to have a strong opinon on this yay or nay, however if we want to make these methods more usable by folks who maybe aren't already Solr coders, could we get some JavaDocs added?

epugh avatar Mar 23 '22 11:03 epugh

Sure thing, I'll take a look over the JavaDocs and add some information there.

paulkiernan avatar Mar 23 '22 17:03 paulkiernan

Wondering if the comparators becoming static and moving into a separate class might also be something to consider, to make them (perhaps) more discoverable for use in tests?

cpoerschke avatar Mar 23 '22 17:03 cpoerschke

@cpoerschke that makes sense to me... @paulkiernan thoughts on moving this forward?

epugh avatar Oct 14 '22 21:10 epugh

This PR had no visible activity in the past 60 days, labeling it as stale. Any new activity will remove the stale label. To attract more reviewers, please tag someone or notify the [email protected] mailing list. Thank you for your contribution!

github-actions[bot] avatar Feb 21 '24 00:02 github-actions[bot]