Posting the specific details of the NPEs you are seeing (ie: stack traces) would help to answer your question.
Some of the functionality in LTC is definitely tied to the JUnit test case lifecycle, so it's certainly possible that some static objects used by static methods aren't being initialized yet when you make your calls from rules -- but ewther that's a bug or a neccessity (ie: maybe can'd do "newSearcher" until the the randomseed is set and that's set y another Rule?) remains to be seen. : Date: Wed, 12 Nov 2014 10:06:36 -0500 : From: Jason Gerlowski <[email protected]> : Reply-To: [email protected] : To: [email protected] : Subject: LuceneTestCase static method usage : : Hi all, : : I'm seeing NPE's when calling static methods on LuceneTestCase (without : extending it). : : I'm trying to write tests for a few classes that interact with Lucene. To : do that, I was trying to create JUnit @Rule ( : https://github.com/junit-team/junit/wiki/Rules) fixtures that I can share : across different test classes. I want these fixtures to use the : randomness/extra-checks found in LuceneTestCase, but I can't extend LTC : because my fixtures already need to extend JUnit's 'Rule' class for JUnit : to know how to use them. : : So instead I wrote the fixtures to access LTC functionality though the : class's static methods (LTC.newDirectory(), LTC.newSearcher(), etc.) : : Is this a valid way to access LTC methods? Is there any special : initialization I need to do before using the class in this way? : : I ask because I've started to see a few occasional NPE's in LTC during : tests that use these fixtures. To an amateur, it looks like some static : fields in LTC aren't being initialized. It's hard to tell whether I should : consider this a bug in the class, or whether I'm using it incorrectly. : : Thanks for any help/insight you can offer! : : Best, : : Jason Gerlowski : : : (I can follow-up with code-snippets that reproduce this issue. I didn't : post them in this email because I thought I might just be misusing : LuceneTestCase). : -Hoss http://www.lucidworks.com/ --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
