lucenenet-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Doug Sale (JIRA)" <>
Subject [jira] Commented: (LUCENENET-127) broken test case: Lucene.Net.Analysis.TestStandardAnalyzer.TestDeprecatedAcronyms()
Date Wed, 06 Aug 2008 23:54:44 GMT


Doug Sale commented on LUCENENET-127:


Intermittent Test Failures

Failing Tests:
- TestDomainNames()
- TestDeprecatedAcronyms()

1) all tests directly after a clean build
  - FAIL: TestDeprecatedAcronyms()
2) TestDeprecatedAcronyms() directly after a clean build
  - PASS
3) TestDomainNames() directly after a clean build:
  - PASS
4) TestDeprecatedAcronyms() directly after successful TestDomainNames()
  - FAIL
5) TestDeprecatedAcronyms() directly after successful TestDeprecatedAcronyms() 
  - PASS
6) TestDomainNames() directly after successful TestDeprecatedAcronyms()
  - PASS
7) TestDomainNames() directly after successful TestDomainNames()
  - FAIL

(Interestingly, I can only recreate cases 4 thru 7 by using the TestRunner testing harness
- apparently it caches object instances between test invocations.  The standard NUnit test
harness only diagnoses a failure in case #1.)

Prior to the last assertion in TestDomainNames(), the following code is invoked:

	((StandardAnalyzer) a).SetReplaceInvalidAcronym(true);

This changes the behavior of the StandardAnalyzer, causing the test failures in subsequent
tests.  'a' is a StandardAnalyzer instance that is an instance variable in TestStandardAnalyzer.

As I mentioned in my earlier post, the reason TestDeprecatedAcronyms() fails in Lucene.Net
but not in Lucene is related to a key difference between NUnit and JUnit:  JUnit uses a new
instance of the test class for every method invocation while NUnit uses a single instance.

The repercussions of this seemingly insignificant difference are that in NUnit, one test case
can alter the execution environment of a subsequent test case.  My prior solution was to create
a StandardAnalyzer instance within TestDeprecatedAcronyms().  Another solution would be to
reset the default state of StandardAnalyzer as the last statement in TestDomainNames():

	((StandardAnalyzer) a).SetReplaceInvalidAcronym(false);

But, the prudent solution is to assign a new instance of StandardAnalyzer to 'a' in a [SetUp]
annotated method.  In fact, all test classes that are converted from Java/JUnit to C#/NUnit
would be assured to be comparing apples to apples if they moved all instance variable initialization
to  a [SetUp] annotated method that is invoked for every test case/method.

Said patch for TestStandardAnalyzer is inbound.

> broken test case: Lucene.Net.Analysis.TestStandardAnalyzer.TestDeprecatedAcronyms()
> -----------------------------------------------------------------------------------
>                 Key: LUCENENET-127
>                 URL:
>             Project: Lucene.Net
>          Issue Type: Bug
>            Reporter: Doug Sale
>            Priority: Minor
>         Attachments: TestStandardAnalyzer.patch
>   Original Estimate: 0h
>  Remaining Estimate: 0h
> Test case TestDeprecatedAcronyms() fails when run with all unit tests in test class TestStandardAnalyzer.cs
but succeeds when run alone.

This message is automatically generated by JIRA.
You can reply to this email to add a comment to the issue online.

View raw message