lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Erick Erickson <erickerick...@gmail.com>
Subject Re: Junit4
Date Thu, 05 Nov 2009 18:24:20 GMT
One other thing I thought of last night: Are there any objections to
deprecating LuceneTestCase? I know we're trying to avoid deprecating things
in 3.0, but since this isn't user-facing it seems reasonable. If it's
deprecated, it'll at least give test writers a hint that junit4 is available
(I'll include some pointers in the javadocs...)...

Erick

On Wed, Nov 4, 2009 at 9:07 PM, Erick Erickson <erickerickson@gmail.com>wrote:

> Now that we're going for Java 5, I took some time this evening to poke at
> using Junit4. I've done enough for proof of concept (POC), but before going
> further I wondered if there's enough interest or cautions or objections.
>
> It's actually not bad. I was afraid that we'd have to do an "all or none"
> conversion, but Junit3 and Junit4 co-exist quite happily both in IntelliJ
> and in ant.
>
> I managed to get all of the tests in
> ...test/org/apache/lucene/search/function to run under junit4, while all the
> rest of the tests are running under Junit3....
>
> The short form is that I made a copy of LuceneTestCase called
> LuceneTestCaseJ4 that does NOT derive from TestCase but preserves (almost)
> all of the other functionality. There's some pesky nonsense with the
> constructor that takes a parameter (apparently disallowed by Junit4, and for
> POC I'm not going to worry about it, I'm not sure this is anything more than
> an artifact of Junit3 and can be removed). From there, it was just a matter
> of making the relevant test cases inherit from LuceneTestCaseJ4 and
> resolving some visibility issues (e.g. the setup and teardown (i.e. @Before
> and @After) in LTCJ4 had to be public), and resolving imports.
>
> I had to hack the common-build.xml a bit (warning, I'm no Ant expert) to
> include both junit jars, but that seems to work fine.
>
> So I *claim* that we can gradually migrate to junit4 if we want to without
> having to do a massive migration. I really haven't looked very carefully at
> the base LuceneTestCase class, but I can successfully comingle Junit3 and
> Junit4 testcases so I thought it was worth discussing. Note that I didn't do
> *anything* except get the tests to run. That is, other than adding things
> like @Before and @After and @Test, I didn't take advantage of any of the
> Junit4 features.
>
> If there's enough interest, I'll clean some things up, make  a JIRA (I
> don't see anything in there already on this topic) and submit a patch in the
> next week. And this is *really* something I'd like someone else's eyes
> on....
>
> Best
> Erick
>

Mime
View raw message