You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucene.apache.org by gquaire <gq...@gmail.com> on 2011/08/04 16:20:36 UTC

Initialization error of Junit tests with solr-test-framework

Hi everybody,

I have a very strange problem. I'm currently developping a new component for
Solr. And in my Netbeans project, I have created two Test classes for this
component: one class for simple unit tests (derived from  SolrTestCaseJ4
class) and a second one for tests with sharding (derived from 
BaseDistributedSearchTestCase).
When I launch a test with these two classes, I have an error in the
initialization of the second class of tests (no matter the class is, this is
always the second executed class which fails). The error comes from an
"assert" which failed in the begining of the function "initRandom()" of
LuceneTestCase class :

/assert !random.initialized;/

But, if I launch each test class separatly, all the tests succeed!

To make an experiment, I changed the source code of the LuceneTestCase
function. I replaced the "assert" with a condition:
 
/if (!random.initialized){ ..}/

With this modification, I lanch the two classes Junit  together and all the
tests succeed.

Does my modification of LuceneTestCase have a sens?

If not, what I do wrong?

Thanks for help!

GQuaire

-----
Jouve ITS France
--
View this message in context: http://lucene.472066.n3.nabble.com/Initialization-error-of-Junit-tests-with-solr-test-framework-tp3225514p3225514.html
Sent from the Lucene - Java Developer mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org


Re: Initialization error of Junit tests with solr-test-framework

Posted by gquaire <gq...@gmail.com>.
OK, I will create a JIRA. The problem exists when building the component with
the command line by Maven.
I use Maven 2.2.1. 
So, I think the issue appeared when tests are launched whith Maven and not
with Ant.



-----
Jouve ITS France
--
View this message in context: http://lucene.472066.n3.nabble.com/Initialization-error-of-Junit-tests-with-solr-test-framework-tp3225514p3227836.html
Sent from the Lucene - Java Developer mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org


Re: Initialization error of Junit tests with solr-test-framework

Posted by Robert Muir <rc...@gmail.com>.
On Thu, Aug 4, 2011 at 11:01 AM, gquaire <gq...@gmail.com> wrote:
> Thanks Mr. Muir for your reply.
>
> Do the suppression of the assert is a good solution to make the classes
> worked in the IDEs?
>
> May I create an issue or task in the Jira ?

You can create a JIRA: I don't think suppression of the assert is a
good solution here, as it will result in us not being able to
reproduce test failures:

The problem is that via ant, tests work like this (e.g. for 3 test classes):
computeTestMethods
beforeClass
afterClass
computeTestMethods
beforeClass
AfterClass
computeTestMethods
beforeClass
afterClass

but via an IDE, if you run it from a folder like you did, then it does this:
computeTestMethods
computeTestMethods
computeTestMethods
beforeClass
afterClass
beforeClass
afterClass
beforeClass
afterClass




-- 
lucidimagination.com

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org


Re: Initialization error of Junit tests with solr-test-framework

Posted by gquaire <gq...@gmail.com>.
Thanks Mr. Muir for your reply.

Do the suppression of the assert is a good solution to make the classes
worked in the IDEs?

May I create an issue or task in the Jira ?


-----
Jouve ITS France
--
View this message in context: http://lucene.472066.n3.nabble.com/Initialization-error-of-Junit-tests-with-solr-test-framework-tp3225514p3225620.html
Sent from the Lucene - Java Developer mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org


Re: Initialization error of Junit tests with solr-test-framework

Posted by Robert Muir <rc...@gmail.com>.
Currently these base classes do not work in this way with IDEs: maybe
we can add a workaround so they do in the future (But still have
correct random behavior).

On Thu, Aug 4, 2011 at 10:20 AM, gquaire <gq...@gmail.com> wrote:
> Hi everybody,
>
> I have a very strange problem. I'm currently developping a new component for
> Solr. And in my Netbeans project, I have created two Test classes for this
> component: one class for simple unit tests (derived from  SolrTestCaseJ4
> class) and a second one for tests with sharding (derived from
> BaseDistributedSearchTestCase).
> When I launch a test with these two classes, I have an error in the
> initialization of the second class of tests (no matter the class is, this is
> always the second executed class which fails). The error comes from an
> "assert" which failed in the begining of the function "initRandom()" of
> LuceneTestCase class :
>
> /assert !random.initialized;/
>
> But, if I launch each test class separatly, all the tests succeed!
>
> To make an experiment, I changed the source code of the LuceneTestCase
> function. I replaced the "assert" with a condition:
>
> /if (!random.initialized){ ..}/
>
> With this modification, I lanch the two classes Junit  together and all the
> tests succeed.
>
> Does my modification of LuceneTestCase have a sens?
>
> If not, what I do wrong?
>
> Thanks for help!
>
> GQuaire
>
> -----
> Jouve ITS France
> --
> View this message in context: http://lucene.472066.n3.nabble.com/Initialization-error-of-Junit-tests-with-solr-test-framework-tp3225514p3225514.html
> Sent from the Lucene - Java Developer mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
> For additional commands, e-mail: dev-help@lucene.apache.org
>
>



-- 
lucidimagination.com

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org