LUCENE-7247: TestCoreParser.dumpResults verbose and test-fail logging tweaks

This commit is contained in:
Christine Poerschke 2016-04-25 09:39:29 +01:00
parent 4ea4adc210
commit fe1ad19af3

View File

@ -221,13 +221,15 @@ public class TestCoreParser extends LuceneTestCase {
protected void dumpResults(String qType, Query q, int numDocs) throws IOException {
if (VERBOSE) {
System.out.println("TEST: qType=" + qType + " query=" + q + " numDocs=" + numDocs);
System.out.println("TEST: qType=" + qType + " numDocs=" + numDocs + " " + q.getClass().getCanonicalName() + " query=" + q);
}
final IndexSearcher searcher = searcher();
TopDocs hits = searcher.search(q, numDocs);
assertTrue(qType + " should produce results ", hits.totalHits > 0);
final boolean producedResults = (hits.totalHits > 0);
if (!producedResults) {
System.out.println("TEST: qType=" + qType + " numDocs=" + numDocs + " " + q.getClass().getCanonicalName() + " query=" + q);
}
if (VERBOSE) {
System.out.println("=========" + qType + "============");
ScoreDoc[] scoreDocs = hits.scoreDocs;
for (int i = 0; i < Math.min(numDocs, hits.totalHits); i++) {
Document ldoc = searcher.doc(scoreDocs[i].doc);
@ -235,5 +237,6 @@ public class TestCoreParser extends LuceneTestCase {
}
System.out.println();
}
assertTrue(qType + " produced no results", producedResults);
}
}