I obviously already went for the first, but I was wondering what will it
happen when my application will grow significantly. On the other hand, I
tried the second one, with fork=true, and:

1) First of all I must admit that I don't know what the impact of this
change will be on the effective application (therefore I won't be able to
solve further bugs)
2) The unit tests fail because the AbstractTest from which they inherit can
find a property file (and because of point 1 I don't know the reason)

Marco
----- Original Message ----- 
From: "Sebastien Sahuc" <[EMAIL PROTECTED]>
To: "Maven Users List" <[EMAIL PROTECTED]>
Sent: Tuesday, February 17, 2004 9:34 PM
Subject: Re: Unit testing question


> I'm not surprised to hear your singleton class is being instanciated
> more than once. This is due to the fact the maven create a separate
> classloader for each TestCase it finds and executes. There is two way
> to quickly solve your problem. First would be to aggregate all test
> cases that use the singleton service into a single test suite and have
> maven run only the test suite and rule out all independent test cases.
> The second solution is simply to fork the junit JVM with the property
> maven.junit.fork=true.
>
> Sebastien
>
> On Feb 17, 2004, at 1:16 PM, Marco Tedone wrote:
>
> > Please find in the attached picture the architecture of my unit
> > testings.
> > Basically, I created two unit test classes which extend and
> > AbstractTest
> > class which, in turn, extends the JUnit TestCase class.
> >
> > Both classes retrieve a logger from a class implemented as Singleton
> > (therefore only one instance should be created). I put a log message
> > in the
> > the constructor to see how many times the constructor gets invoked (and
> > actually it is invoked twice while it should be invoked only once as
> > this is
> > a singleton).
> >
> > Attached you will find the unit test classes, logger factory and a PDF
> > with
> > the dump of the unit test activity, showing the message logged from the
> > Singleton constructor. For simplicity, the diagram doesn't show the
> > package
> > hierarchy, which is available on request.
> >
> > If you really want to run the application, you may want to download it
> > and
> > the logging framework, following the instructions at the following
> > site:
> >
> > http://www.jemos.org
> >
> > Best Regards,
> >
> > Marco
> >
> > ----- Original Message -----
> > From: "Charles Daniels" <    >
> > To: "Maven-users" <[EMAIL PROTECTED]>
> > Sent: Tuesday, February 17, 2004 7:21 AM
> > Subject: Re: Unit testing question
> >
> >
> >> This sounds more like a problem with the way you have implemented your
> > unit tests, not a problem
> >> with Maven.  Can you provide more details on how you have written your
> > test classes?
> >>
> >> --- Marco Tedone <[EMAIL PROTECTED]> wrote:
> >>> Hi, I build my projects using maven. Maven executes automatically
> >>> junit
> > tests. I've got more
> >>> than one test. Both of those tests use the services offered by a
> >>> class,
> > which I've implemented
> >>> as a Singleton. The class is created after each test class has
> > completed, thus my singleton is
> >>> like as it doesn't exist.
> >>>
> >>> Is there a solution to this problem?
> >>>
> >>> Marco
> >>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: [EMAIL PROTECTED]
> >> For additional commands, e-mail: [EMAIL PROTECTED]
> >>
> >>
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to