Test failure question

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Test failure question

George Aroush
Hi folks,

I realize this question is not directly related to Lucene, but I believe
it's worth asking.

With Lucene.Net (for those who don't know, is a port of Jakarta Lucene from
Java to C#) I use NUnit to test the same test code (ported to C#) that JUnit
test.  When I run the NUnit test there are 3 separate test cases where the
test is failing if the test is run as a group but will pass if each of those
tests run individually.

For example, the tests in TestPhraseQuery, which has
testBarelyCloseEnough(), testExact(), testMulipleTerms(), etc.  When I run
the entire test cases by selecting TestPhraseQuery node, the test starts
from the top to bottom and testMulipleTerms() will fail.  But if I run
testMulipleTerms() by itself it will pass.  The fail point is on the first
assert line in testMulipleTerms() -- which is (in the NUnit world):

        Assert.AreEqual(1, hits.Length(), "two total moves");

My question to you is this: does anyone know if JUnit will call setUP() and
tearDown() before and after each test method call or is setUp()/tearDown()
are only called once at test startup and shutdown?  The fail is, I am
getting back a 0, where the expected value should be 1.

Knowing this will help me diagnoses the problem.

Regards,

-- George


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Test failure question

Simon Willnauer
On 6/16/06, George Aroush <[hidden email]> wrote:

> Hi folks,
>
> I realize this question is not directly related to Lucene, but I believe
> it's worth asking.
>
> With Lucene.Net (for those who don't know, is a port of Jakarta Lucene from
> Java to C#) I use NUnit to test the same test code (ported to C#) that JUnit
> test.  When I run the NUnit test there are 3 separate test cases where the
> test is failing if the test is run as a group but will pass if each of those
> tests run individually.
>
> For example, the tests in TestPhraseQuery, which has
> testBarelyCloseEnough(), testExact(), testMulipleTerms(), etc.  When I run
> the entire test cases by selecting TestPhraseQuery node, the test starts
> from the top to bottom and testMulipleTerms() will fail.  But if I run
> testMulipleTerms() by itself it will pass.  The fail point is on the first
> assert line in testMulipleTerms() -- which is (in the NUnit world):
>
>         Assert.AreEqual(1, hits.Length(), "two total moves");
>
> My question to you is this: does anyone know if JUnit will call setUP() and
> tearDown() before and after each test method call or is setUp()/tearDown()
> are only called once at test startup and shutdown?  The fail is, I am
> getting back a 0, where the expected value should be 1.
>
setUp and tearDown will be called before and after each test runs!
http://www.junit.org/junit/javadoc/3.8.1/junit/framework/TestCase.html#setUp()
and I bet it is the same in NUnit

simon
This is rather a junit questing

> Knowing this will help me diagnoses the problem.
>
> Regards,
>
> -- George
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

RE: Test failure question

George Aroush
Hi Simon and all,

It's not clear to me when setUp()/tearDown() is called.  Are they called
before/after each call to testBarelyCloseEnough(), testExact(),
testMulipleTerms(), etc?  If so, then the NUnit is not doing this.  I tested
by outputing to stdout.

I don't have JUnit setup to see what it does, so if someone who has it setup
can test and post here I would really appreciate it.

Regards,

-- George

-----Original Message-----
From: Simon Willnauer [mailto:[hidden email]]
Sent: Friday, June 16, 2006 12:39 PM
To: [hidden email]
Subject: Re: Test failure question

On 6/16/06, George Aroush <[hidden email]> wrote:

> Hi folks,
>
> I realize this question is not directly related to Lucene, but I
> believe it's worth asking.
>
> With Lucene.Net (for those who don't know, is a port of Jakarta Lucene
> from Java to C#) I use NUnit to test the same test code (ported to C#)
> that JUnit test.  When I run the NUnit test there are 3 separate test
> cases where the test is failing if the test is run as a group but will
> pass if each of those tests run individually.
>
> For example, the tests in TestPhraseQuery, which has
> testBarelyCloseEnough(), testExact(), testMulipleTerms(), etc.  When I
> run the entire test cases by selecting TestPhraseQuery node, the test
> starts from the top to bottom and testMulipleTerms() will fail.  But
> if I run
> testMulipleTerms() by itself it will pass.  The fail point is on the
> first assert line in testMulipleTerms() -- which is (in the NUnit world):
>
>         Assert.AreEqual(1, hits.Length(), "two total moves");
>
> My question to you is this: does anyone know if JUnit will call
> setUP() and
> tearDown() before and after each test method call or is
> setUp()/tearDown() are only called once at test startup and shutdown?  
> The fail is, I am getting back a 0, where the expected value should be 1.
>
setUp and tearDown will be called before and after each test runs!
http://www.junit.org/junit/javadoc/3.8.1/junit/framework/TestCase.html#setUp
()
and I bet it is the same in NUnit

simon
This is rather a junit questing

> Knowing this will help me diagnoses the problem.
>
> Regards,
>
> -- George
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

RE: Test failure question

Pasha Bizhan-2
Hi,

> testBarelyCloseEnough(), testExact(), testMulipleTerms(),
> etc?  If so, then the NUnit is not doing this.  I tested by
> outputing to stdout.

NUnit calls setUp before each test and calls tearDown after each test.
Add Console.WriteLine and see the result.

Let me show:
------------------
        [TestFixture]
        public class TestPhraseQuery {
                [SetUp]
                protected void SetUp() {
                        directory = new RAMDirectory();
                        IndexWriter writer = new IndexWriter(directory, new
WhitespaceAnalyzer(), true);
                        ...
                        Console.WriteLine("set up");
                }


                [TearDown]
                protected void TearDown() {
                        searcher.Close(); directory.Close();
                        Console.WriteLine("tear down");
                }


                [Test]
                public void TestNotCloseEnough()  {
                        query.SetSlop(2);
                        .....
                        MockAssert.AreEqual(0, hits.Length());
                        Console.WriteLine("not close");
                }
------------------
The output:
---------------
set up
barely
tear down

set up
tear down
...
----------------

Pasha Bizhan


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

RE: Test failure question

George Aroush
Hi Pasha,

That is defiantly not happening in my case.  Here is an output:

Setup()
TestBarelyCloseEnough()
TestExact()
TestMulipleTerms()
TestNotCloseEnough()
TestOrderDoesntMatter()
TestPhraseQueryInConjunctionScorer()
TestPhraseQueryWithStopAnalyzer()
TestSlop1()
TestSlopScoring()
TestWrappedPhrase()
TearDown()

Which version of NUnit are you using?  I am using 2.2.8.

Regards,

-- George

-----Original Message-----
From: Pasha Bizhan [mailto:[hidden email]]
Sent: Friday, June 16, 2006 2:07 PM
To: [hidden email]
Subject: RE: Test failure question

Hi,

> testBarelyCloseEnough(), testExact(), testMulipleTerms(), etc?  If so,
> then the NUnit is not doing this.  I tested by outputing to stdout.

NUnit calls setUp before each test and calls tearDown after each test.
Add Console.WriteLine and see the result.

Let me show:
------------------
        [TestFixture]
        public class TestPhraseQuery {
                [SetUp]
                protected void SetUp() {
                        directory = new RAMDirectory();
                        IndexWriter writer = new IndexWriter(directory, new
WhitespaceAnalyzer(), true);
                        ...
                        Console.WriteLine("set up");
                }


                [TearDown]
                protected void TearDown() {
                        searcher.Close(); directory.Close();
                        Console.WriteLine("tear down");
                }


                [Test]
                public void TestNotCloseEnough()  {
                        query.SetSlop(2);
                        .....
                        MockAssert.AreEqual(0, hits.Length());
                        Console.WriteLine("not close");
                }
------------------
The output:
---------------
set up
barely
tear down

set up
tear down
...
----------------

Pasha Bizhan


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

RE: Test failure question

Pasha Bizhan-2
Hi,

> From: George Aroush [mailto:[hidden email]]
>
> That is defiantly not happening in my case.  Here is an output:
>
> Which version of NUnit are you using?  I am using 2.2.8.

2.2.0.

But I've downloaded 2.2.8 and test it. It produces the same results:
setUp is called before each test and tearDown is called after.

Pasha Bizhan



---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]