lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Erick Erickson <erickerick...@gmail.com>
Subject Re: Uwe's question
Date Fri, 26 Feb 2010 18:16:45 GMT
You can use Junit4 whenever you want right now. Just derive from
LuceneTestCaseJ4 rather than LuceneTestCase. And annotate
each test with @Test and you should be fine.

Junit4 does allow you to mix-n-match 3/4 tests
*on a whole class basis*. That is, all of the tests in a class must
be either 3-style deriving from TestCase and named appropriately)
or 4-style (annotated, with whatever Junit4 features you'd like).

The consensus seems to be that converting old tests to
Junit4 just to get them all using Junit4 isn't a good use
of time, and at least introduces the possibility that it would
mess things up. Upgrading old tests to Junit4 to improve
them, especially to speed them up (@BeforeClass and @
AfterClass can help) *is* a good use of time.

I might convert an old-style test case if I was
working in it, but that's probably a personal preference.

I've never tried to learn a command-line invocation of a test
case for a single test method, I've always just used the IDE
to run individual methods....

Erick

On Fri, Feb 26, 2010 at 11:31 AM, Jason Rutherglen <
jason.rutherglen@gmail.com> wrote:

> Lets go to JUnit 4 if possible...
>
> Does it provide method level testing?  (i.e. one doesn't need to
> execute every test method just to check the results of one method)
>
> On Thu, Feb 25, 2010 at 8:15 PM, Shai Erera <serera@gmail.com> wrote:
> > Ok this seems a discussion related to JUnit 4, so I'll port what I've
> said
> > about it from the other thread (doing the code cleanup):
> >
> > {quote}
> > Erik, I'm totally with you on JUnit 4. I think the @Test annotation is
> > really not a big deal (it's actually very easy to migrate all the current
> > tests to JUnit 4 with the added import using some script. Even manually
> it
> > shouldn't be such a big deal.
> >
> > @Ignore is a perfect other advantage of JUnit4. I've found some tests
> which
> > were prefixed with _, i.e. _testXYZ just to disable them. Nobody knows
> about
> > them until he looks at the code (and pays attention). @Ignore would have
> > been better.
> >
> > And there are lots of other advantages, like the @Before and @After (not
> > only class). Another problem I've found in the tests is that not all
> > extended LuceneTestCase, and usually their setUp and tearDown
> > implementations were wrong - not calling super first/last. When I moved
> them
> > to extend LuceneTestCase they broke (I fixed them, don't worry). However,
> > that could never happen if the super's methods were tagged w/
> @Before/After,
> > because JUnit would take care running them before/after their
> sub-classes'
> > @Before/After. So that's another win for JUnit4.
> >
> > And of course the @Before/AfterClass are really great !
> > {quote}
> >
> > I think the @Before/After annotations can be a real win for our tests.
> >
> > My two cents,
> > Shai
> >
> > On Fri, Feb 26, 2010 at 4:57 AM, Erick Erickson <erickerickson@gmail.com
> >
> > wrote:
> >>
> >> Well, "Things got busy (tm)". Uwe's point if valid; unless there's
> >> demonstrable gain, moving things to Junit4 "just for fun" is wasted
> motion,
> >> indeed dangerous. I was focusing on LocalizedTestCase to understand the
> >> place of runBare etc. in the scheme of things since when I created
> >> LuceneTestCaseJ4 that was something I wanted to figure out to make it a
> >> replacement for LuceneTestCase.
> >>
> >> I can't point to a compelling reason to shake up the code, the only
> >> improvement it would have is having a demonstration of using the Junit4
> >> @RunWith annotation for future reference.
> >>
> >> So, I've no compelling reason to push that patch forward. If y'all think
> >> it's worth it I'll be happy to crank that patch back up again, it'll
> take a
> >> few days though. It does affect a several files, and if the main value
> here
> >> is an exemplar of the @RunWith annotation, perhaps there's a better
> place to
> >> put that in.
> >>
> >> Erick
> >>
> >> On Thu, Feb 25, 2010 at 9:06 PM, Robert Muir <rcmuir@gmail.com> wrote:
> >>>
> >>>
> >>>>
> >>>> LocalizedTestCase called runBare in LuceneTestCase which reported the
> >>>> seed value if an exception was thrown. I couldn't find a good way to
> access
> >>>> runBare or analogs in Junit4, but the interceptor pattern worked as
> well.
> >>>> The interceptor is called by the Junit framework on test events, so
> there
> >>>> aren't references to it in the Lucene test code. There are other
> places that
> >>>> call runBare, so I assumed that if anyone wanted to use Junit4 with
> those
> >>>> classes it would be a good thing to allow.
> >>>
> >>> I didn't forget about your patch Erick, in my opinion there is nothing
> >>> wrong with it. I hope its not discouraging you, the problem is a few of
> us
> >>> have spent countless hours trying to debug this hard-to-reproduce Thai
> test
> >>> failure problem.
> >>>
> >>> It failed in the existing tests, too, with Junit 3 on hudson (one
> time!).
> >>> At this point, i start to wonder if it could be related to stuff like
> this:
> >>> http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6683975
> >>>
> >>> I don't think we should let this stop progress with the tests, if you
> >>> think we should move LocalizedTestCase to junit 4 lets do it.
> >>>
> >>> --
> >>> Robert Muir
> >>> rcmuir@gmail.com
> >>
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-dev-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-dev-help@lucene.apache.org
>
>

Mime
View raw message