Are you asking how to test your own code, that happens to have a solr query somewhere in the middle of it? I've done this two ways:
1) You can mock the solr call by detecting that you are in test mode and just return the right answer. That will be fast. 2) Or you set up a second core with the name "test", and initialize it for each test. That will give you confidence that your queries are formed correctly. Since your test data is generally really small, I've found that using the second method performs well enough. I use a global in my app that contains the name of the core, and I set that in a before filter in application_controller depending whether I'm in test mode or not. As part of the test set up I delete all documents. The "delete *:*" call is really fast. Then I commit a dozen documents or so. With that little data that is fast, too. I wrap all calls to solr in a single model so there is one point in my app that calls rsolr. I can override that class to mock it out if the solr result is not the focus of the test, and do the above work if the solr result is the focus of the test. > > On Feb 17, 2012, at 07:12 , solr wrote: > >> Hi all, >> Am writing rails application by using solr_ruby gem to access solr . >> Can anybody suggest how to handle testcaeses for solr code and connections >> in functionaltetsing. >>