It's embarrassing that I had to poke around for 1/2 hour to find *code that
I had written recently*. siiiggghhh. Maybe this time it'll stick....

In LuceneTestCaseJ4, we added an @Rule-annotated class
InterceptTestCaseEvents whose methods get called whenever an "event"
happens, things like succeeded, failed, started, etc.. The failed method
looks for a method in the failing class called reportAdditionalFailureInfo.
So by adding something like the below to LocalizedTestCase you can print any
information you have available whenever things fail. It gets printed in
addition to the usual information Junit prints. Warning: I tested this
*very* lightly, at least it worked in the one case I tried..

  @Override
  public void reportAdditionalFailureInfo() {
    System.out.println("Failing locale is" +
_currentLocale.getDisplayName(_origDefault));
    super.reportAdditionalFailureInfo(); // call to super.report.....
UNTESTED! and probably not necessary in this context. Left as an exercise
for the reader <G>.
  }

Currently this is only does extra stuff for failed cases, but it would be
trivial to extend for start, end, succeeded whenever there's a need.

Your second question seems quite do-able,just by putting the default locale
in the list before getting into the loop as the first entry. I'm not sure
removing the default language is worth the effort, so it gets run twice. But
if you're writing the code, do whatever you want.

Gotta get some sleep <G>...

Erick

On Wed, Dec 9, 2009 at 9:45 PM, Robert Muir (JIRA) <j...@apache.org> wrote:

>
>    [
> https://issues.apache.org/jira/browse/LUCENE-2122?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12788455#action_12788455]
>
> Robert Muir commented on LUCENE-2122:
> -------------------------------------
>
> thanks Erick, i will play around with the patch some, generally just
> double-check the locale stuff is doing what we want, looks like it will.
>
> i havent tested yet, but looking at the code i have a few questions (i can
> try to add these to the patch just curious what you think):
> 1. if a test fails under some locale, say th_TH, will junit 4 attempt to
> print this parameter out in some way so I know that it failed? If not do you
> know of a hack?
> 2. i am thinking about reordering the locale array so that it tests the
> default one first. if you are trying to do some test-driven dev it might be
> strange if the test fails under a different locale first. I think this one
> is obvious, I will play with it to see how it behaves now.
>
>
> > Use JUnit4 capabilites for more thorough Locale testing for classes
> deriving from LocalizedTestCase
> >
> ---------------------------------------------------------------------------------------------------
> >
> >                 Key: LUCENE-2122
> >                 URL: https://issues.apache.org/jira/browse/LUCENE-2122
> >             Project: Lucene - Java
> >          Issue Type: Improvement
> >          Components: Other
> >    Affects Versions: 3.1
> >            Reporter: Erick Erickson
> >            Assignee: Robert Muir
> >            Priority: Minor
> >             Fix For: 3.1
> >
> >         Attachments: LUCENE-2122-r2.patch, LUCENE-2122-r3.patch,
> LUCENE-2122-r4.patch, LUCENE-2122.patch
> >
> >
> > Use the @Parameterized capabilities of Junit4 to allow more extensive
> testing of Locales.
>
> --
> This message is automatically generated by JIRA.
> -
> You can reply to this email to add a comment to the issue online.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-dev-unsubscr...@lucene.apache.org
> For additional commands, e-mail: java-dev-h...@lucene.apache.org
>
>

Reply via email to