You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cactus-user@jakarta.apache.org by Chris May <ch...@warwick.ac.uk> on 2004/05/10 13:06:25 UTC

Jetty integration - running individual tests

Hi all,

I'm experimenting with using the Cactus Jetty integration, as per 
http://jakarta.apache.org/cactus/integration/integration_jetty.html, to 
unit-test JSPs and JSP2 tag files. So far so good - works great, and 
about a hundred times quicker than my previous method of deploying a 
WAR and using HttpUnit. However, I have a some questions:

The way that the Jetty server is started and stopped is with a custom 
TestSuite (JettyTestSuite) - so I have to make a decision in my code 
about when I want the server started and stopped.
I can write a test suite that runs the entire set of JSP tests 
(starting Jetty once when the suite starts), or I can write a suite() 
method on each test class (starting Jetty once per class when I run all 
of them), or I can write intermediate-sized suites that run some, but 
not all, of my test classes.

But what I'd like to be able to do is have more dynamic control than 
this. For example,

  - when I run the full suite and get 1 failure, I'd like to be able to 
run just that one individual test method without even the rest of it's 
class.

  - I'd like to not have to remember to add a suite() method to every 
new JSP test class I write, or remember to have to add a reference to 
each new test class to an 'AllJSPTests' class

- when I run the full test suite I only want Jetty to start up once, 
but I'd still like to be able to run individual classes and have them 
start and stop Jetty for me.

I suppose that some of this functionality might be in the provided by 
the Eclipse plugin (I'm using 3.0 M8+) so perhaps one way to meet my 
needs  would be for me to help fix that, but I wonder if this is a 
problem that anyone else has experienced and/or worked around, and that 
might have a solution which is not IDE-specific.

It seems to me that perhaps it would be possible to write a custom 
extension to TestCase, with a smart setUp/tearDown that could 
start/stop jetty only if necessary. Does that sound like it would work?

Thanks in advance

Chris



RE: Jetty integration - running individual tests

Posted by Vincent Massol <vm...@pivolis.com>.

> -----Original Message-----
> From: Vincent Massol [mailto:vmassol@pivolis.com]
> Sent: 14 May 2004 15:36
> To: 'Cactus Users List'
> Subject: RE: Jetty integration - running individual tests
> 
> Hi Chris,
> 
> I've just committed the change in Cactus CVS HEAD. JettyTestSetup now
> checks if jetty is already started. If so, it doesn't start it again
nor
> does it stop it.
> 
> This way you can have:
> 
> - MyTestCase1 with a suite() method
> - MyTestCaseN with a suite() method
> - TestAll which adds all MyTestCaseN classes
> 
> and be able to execute each of them with no change.
> 
> I'll release a 1.7dev nightly build sometime this week end.

Done (in advance). It's available under
http://cvs.apache.org/builds/jakarta-cactus/nightly/2004-05-14/

[snip]

Thanks
-Vincent



RE: Jetty integration - running individual tests

Posted by Vincent Massol <vm...@pivolis.com>.
Hi Chris,

I've just committed the change in Cactus CVS HEAD. JettyTestSetup now
checks if jetty is already started. If so, it doesn't start it again nor
does it stop it.

This way you can have:

- MyTestCase1 with a suite() method
- MyTestCaseN with a suite() method
- TestAll which adds all MyTestCaseN classes

and be able to execute each of them with no change.

I'll release a 1.7dev nightly build sometime this week end.

Thanks
-Vincent

> -----Original Message-----
> From: Chris May [mailto:chris.may@warwick.ac.uk]
> Sent: 11 May 2004 09:53
> To: Cactus Users List
> Subject: Re: Jetty integration - running individual tests
> 
> 
> On 10 May 2004, at 20:04, Vincent Massol wrote:
> 
> > I'd be happy to change the way it works if you can find a solution.
> >
> > Then only solution I can think of for now is for you to have a
suite()
> > method in each of your test case classe. Then we could modify the
> > existing JettyTestSetup class to not start/stop the server if it's
> > already running. Would that do it for you?
> >
> 
> That would certainly improve things performance-wise. The ability to
> run a single test method from the IDE is nice, but it's a long way off
> essential, and this would seem to solve every other issue that I have.
> 
> 
> Many thanks.
> 
> Chris
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: cactus-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: cactus-user-help@jakarta.apache.org




Re: Jetty integration - running individual tests

Posted by Chris May <ch...@warwick.ac.uk>.
On 10 May 2004, at 20:04, Vincent Massol wrote:

> I'd be happy to change the way it works if you can find a solution.
>
> Then only solution I can think of for now is for you to have a suite()
> method in each of your test case classe. Then we could modify the
> existing JettyTestSetup class to not start/stop the server if it's
> already running. Would that do it for you?
>

That would certainly improve things performance-wise. The ability to 
run a single test method from the IDE is nice, but it's a long way off 
essential, and this would seem to solve every other issue that I have.


Many thanks.

Chris


RE: Jetty integration - running individual tests

Posted by Vincent Massol <vm...@pivolis.com>.
Hi Chris,

> -----Original Message-----
> From: Chris May [mailto:chris.may@warwick.ac.uk]
> Sent: 10 May 2004 13:06
> To: cactus-user@jakarta.apache.org
> Subject: Jetty integration - running individual tests
> 
> Hi all,
> 
> I'm experimenting with using the Cactus Jetty integration, as per
> http://jakarta.apache.org/cactus/integration/integration_jetty.html,
to
> unit-test JSPs and JSP2 tag files. So far so good - works great, and
> about a hundred times quicker than my previous method of deploying a
> WAR and using HttpUnit. However, I have a some questions:
> 
> The way that the Jetty server is started and stopped is with a custom
> TestSuite (JettyTestSuite) - so I have to make a decision in my code
> about when I want the server started and stopped.

Exactly. That was done on purpose as we wanted to leave you the choice
to run it with any container you may wish. Using a suite allows us 2
things:
- non-intrusiveness WRT the test (kind of an Aspect... ;-))
- ability to have a global setUp()/tearDown() method to start/stop the
server

> I can write a test suite that runs the entire set of JSP tests
> (starting Jetty once when the suite starts), or I can write a suite()
> method on each test class (starting Jetty once per class when I run
all
> of them), or I can write intermediate-sized suites that run some, but
> not all, of my test classes.
> 
> But what I'd like to be able to do is have more dynamic control than
> this. For example,
> 
>   - when I run the full suite and get 1 failure, I'd like to be able
to
> run just that one individual test method without even the rest of it's
> class.
> 
>   - I'd like to not have to remember to add a suite() method to every
> new JSP test class I write, or remember to have to add a reference to
> each new test class to an 'AllJSPTests' class
> 
> - when I run the full test suite I only want Jetty to start up once,
> but I'd still like to be able to run individual classes and have them
> start and stop Jetty for me.
> 
> I suppose that some of this functionality might be in the provided by
> the Eclipse plugin (I'm using 3.0 M8+) so perhaps one way to meet my
> needs  would be for me to help fix that, but I wonder if this is a
> problem that anyone else has experienced and/or worked around, and
that
> might have a solution which is not IDE-specific.

The Eclipse plugin should not be used. It has been decommissioned.

> 
> It seems to me that perhaps it would be possible to write a custom
> extension to TestCase, with a smart setUp/tearDown that could
> start/stop jetty only if necessary. Does that sound like it would
work?

The problem is that I have not found a nice way to do this. There is no
lifecycle hook to do this in JUnit. Or rather, there is one: it's by
providing a TestSetup/TestSuite.

I'd be happy to change the way it works if you can find a solution. 

Then only solution I can think of for now is for you to have a suite()
method in each of your test case classe. Then we could modify the
existing JettyTestSetup class to not start/stop the server if it's
already running. Would that do it for you?

Thanks
-Vincent