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 "Rajagopal. V" <ra...@yahoo.com> on 2003/09/15 23:15:20 UTC

setUp and TearDown for specific Test Cases

Is there any way you can write a testcase specific
Setup and TearDown method? the setup and tearDown are
run for every single testcase , if i need to have some
setup and teardown for testcases 1, 3 and 5, how would
i go about it. 
For e.g. i need to create a few entities before i
invoke a test. Yeah, i can write this in my beginXXX
and endXXX but if i use this, i cannot use any
container specific APIs or i would need to add
jndi.properties or the like to my cactus war(as they
would not be run in the client). 
So is there any way like a setupXXX and tearDownXXX
that will be invoked before and after testXXX?

TIA
Raj

__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com

RE: setUp and TearDown for specific Test Cases

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

TestClass1 extends TestCase (or ServletTestCase or whatever)
{
protected void setUp()
{
[...]
}

public void test1()
{
[...]
}

public void test3()
{
[...]
}

public void test5()
{
[...]
}
}


TestClass2 extends TestCase (or ServletTestCase or whatever)
{
protected void setUp()
{
[...]
}

public void test2()
{
[...]
}

[...]
}

However, for general JUnit questions, please use the Junit mailing list
(you'll get better answers there). Unless I don't understand your
questions... ;-)

Thanks
-Vincent

> -----Original Message-----
> From: Rajagopal. V [mailto:raja0576@yahoo.com]
> Sent: 15 September 2003 23:32
> To: Cactus Users List
> Subject: RE: setUp and TearDown for specific Test Cases
> 
> Hi Vincent
> Sorry if i dint get you right, but i want some
> pre-conditions to be established before i run my test.
> 
> If i create these preconditions as test cases, i dont
> have a guarantee that they wud be run before my actual
> test cases, right?
> I want to make the preconditions run first and then
> the actual test cases.
> 
> Thanks
> Raj
> 
> --- Vincent Massol <vm...@pivolis.com> wrote:
> >
> >
> > > -----Original Message-----
> > > From: Rajagopal. V [mailto:raja0576@yahoo.com]
> > > Sent: 15 September 2003 23:15
> > > To: cactus-user@jakarta.apache.org
> > > Subject: setUp and TearDown for specific Test
> > Cases
> > >
> > > Is there any way you can write a testcase specific
> > > Setup and TearDown method? the setup and tearDown
> > are
> > > run for every single testcase , if i need to have
> > some
> > > setup and teardown for testcases 1, 3 and 5, how
> > would
> > > i go about it.
> >
> > Easy. Simply create different test cases! JUnit
> > tests must be structured
> > around their fixture, i.e. have a different test
> > case per fixture.
> >
> > So in your case, you'll have one test case for tests
> > 1, 3 and 5 and
> > another test case for the other tests.
> >
> > -Vincent
> >
> > > For e.g. i need to create a few entities before i
> > > invoke a test. Yeah, i can write this in my
> > beginXXX
> > > and endXXX but if i use this, i cannot use any
> > > container specific APIs or i would need to add
> > > jndi.properties or the like to my cactus war(as
> > they
> > > would not be run in the client).
> > > So is there any way like a setupXXX and
> > tearDownXXX
> > > that will be invoked before and after testXXX?
> > >
> > > TIA
> > > Raj


RE: setUp and TearDown for specific Test Cases

Posted by "Rajagopal. V" <ra...@yahoo.com>.
Hi Vincent
Sorry if i dint get you right, but i want some
pre-conditions to be established before i run my test.

If i create these preconditions as test cases, i dont
have a guarantee that they wud be run before my actual
test cases, right? 
I want to make the preconditions run first and then
the actual test cases.

Thanks
Raj

--- Vincent Massol <vm...@pivolis.com> wrote:
> 
> 
> > -----Original Message-----
> > From: Rajagopal. V [mailto:raja0576@yahoo.com]
> > Sent: 15 September 2003 23:15
> > To: cactus-user@jakarta.apache.org
> > Subject: setUp and TearDown for specific Test
> Cases
> > 
> > Is there any way you can write a testcase specific
> > Setup and TearDown method? the setup and tearDown
> are
> > run for every single testcase , if i need to have
> some
> > setup and teardown for testcases 1, 3 and 5, how
> would
> > i go about it.
> 
> Easy. Simply create different test cases! JUnit
> tests must be structured
> around their fixture, i.e. have a different test
> case per fixture.
> 
> So in your case, you'll have one test case for tests
> 1, 3 and 5 and
> another test case for the other tests.
> 
> -Vincent
> 
> > For e.g. i need to create a few entities before i
> > invoke a test. Yeah, i can write this in my
> beginXXX
> > and endXXX but if i use this, i cannot use any
> > container specific APIs or i would need to add
> > jndi.properties or the like to my cactus war(as
> they
> > would not be run in the client).
> > So is there any way like a setupXXX and
> tearDownXXX
> > that will be invoked before and after testXXX?
> > 
> > TIA
> > Raj
> > 
> > __________________________________
> > Do you Yahoo!?
> > Yahoo! SiteBuilder - Free, easy-to-use web site
> design software
> > http://sitebuilder.yahoo.com
> > 
> >
>
---------------------------------------------------------------------
> > To unsubscribe, e-mail:
> cactus-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail:
> cactus-user-help@jakarta.apache.org
> 
> 
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> cactus-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail:
> cactus-user-help@jakarta.apache.org
> 


__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com

RE: setUp and TearDown for specific Test Cases

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

> -----Original Message-----
> From: Rajagopal. V [mailto:raja0576@yahoo.com]
> Sent: 15 September 2003 23:15
> To: cactus-user@jakarta.apache.org
> Subject: setUp and TearDown for specific Test Cases
> 
> Is there any way you can write a testcase specific
> Setup and TearDown method? the setup and tearDown are
> run for every single testcase , if i need to have some
> setup and teardown for testcases 1, 3 and 5, how would
> i go about it.

Easy. Simply create different test cases! JUnit tests must be structured
around their fixture, i.e. have a different test case per fixture.

So in your case, you'll have one test case for tests 1, 3 and 5 and
another test case for the other tests.

-Vincent

> For e.g. i need to create a few entities before i
> invoke a test. Yeah, i can write this in my beginXXX
> and endXXX but if i use this, i cannot use any
> container specific APIs or i would need to add
> jndi.properties or the like to my cactus war(as they
> would not be run in the client).
> So is there any way like a setupXXX and tearDownXXX
> that will be invoked before and after testXXX?
> 
> TIA
> Raj
> 
> __________________________________
> Do you Yahoo!?
> Yahoo! SiteBuilder - Free, easy-to-use web site design software
> http://sitebuilder.yahoo.com
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: cactus-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: cactus-user-help@jakarta.apache.org