简体   繁体   中英

How to debug Solr test cases in Eclipse?

When I try to run a Solr test case from Eclipse (Right-Click > Run As > JUnit Test), I get the following printed to the Eclipse console:

Feb 27, 2012 5:21:06 PM org.apache.solr.SolrTestCaseJ4 deleteCore
INFO: ###deleteCore

The whole process runs and exits very quickly without running the actual test case.

I have tried to set my working directory according to the instructions at http://wiki.apache.org/solr/TestingSolr to no avail. Those instructions refer to a directory that doesn't actually exist any more (src/test/test-files), so I tried setting it to solr/core/src/test-files without any luck. I'm using the latest SOLR trunk (as of Feb 27,2012)

What am I missing?

I hadn't noticed it before, but the test case was throwing an exception saying

A SPI class of type org.apache.lucene.codecs.Codec with name 'Lucene40' does not exist. You need to add the corresponding JAR file supporting this SPI to your classpath.The current classpath supports the following names: []

I solved the problem by adding lucene/build/core/lucene-core-4.0-SNAPSHOT.jar to the classpath in the test case's Run Configuration. It feels like I shouldn't have to do this, but I don't have time to investigate further.

If anyone else can tell me how to remove this dependency, I'll attribute the answer to you.

I also had to set the working directory in my Run Configuration to solr/core/src/test-files

From your own answer looks like you're adding to the classpath a jar which contains the code which should already be in your workspace, thus in your classpath. The Solr build file has a really handy eclipse target which generates the eclipse project, so you can import it in one click. Just run ant eclipse from the root directory and you shouldn't have problems with classpath.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM