Method dependency issues

6 views
Skip to first unread message

Lidia

unread,
Nov 6, 2009, 9:35:40 PM11/6/09
to testng-users
Hello

I have some basic questions related to method dependency. I have the
following test:

@Test (groups = {"jsf", "ajax", "crossbrowser"})
public class TestCrossbrowserUpdateAttr extends SeleneseTestCase {
(...)

@BeforeSuite(alwaysRun = true)
@Test
public void setUp(){
(start selenium here, open start page, etc)
}

@Test (dependsOnMethods = {"setUp"})
public void test1() throws Exception {
(test logic)
}

@Test (dependsOnMethods = {"test1"},
alwaysRun = true)
public void test2() throws Exception{
(test logic)
}

@AfterSuite(alwaysRun = true)
@Test (dependsOnMethods = {"test2"})
public void stopTest() {
(stop selenium, closes browser windows, etc)
}

The problem with this design is that when test2 fails, stopTest is
skipped. I thought that with alwaysRun=true this method would always
get called. How can I assure that it is always called?

I have another test class, where I have about 8 tests that are
independent of each other, and thus I made all of them dependent only
on setUp(). However, I am not certain how I can tie in the stopTest()
method. It does not depend on any other method in particular but
needs to be executed once all the test methods complete. What's the
correct approach here?

Thanks
Lidia

Cédric Beust ♔

unread,
Nov 6, 2009, 11:04:38 PM11/6/09
to testng...@googlegroups.com
Hi Lidia,

You should not be mixing @Test with @AfterSuite, you should break down this code in two categories (which one is really a test and which one is used to tear down your test) and put these in separate methods.

Can you do this and post your updated code if you're still having problems?

--
Cedric
--
Cédric


Lidia

unread,
Nov 10, 2009, 5:58:58 PM11/10/09
to testng-users
After removing @Test annotation for setUp and dependency of tests on
setUp, it all works fine.

Thanks!
Lidia
> ***Cédric
> *

Cédric Beust ♔

unread,
Nov 10, 2009, 6:02:03 PM11/10/09
to testng...@googlegroups.com
On Tue, Nov 10, 2009 at 2:58 PM, Lidia <lid...@gmail.com> wrote:

After removing @Test annotation for setUp and dependency of tests on
setUp, it all works fine.

Glad to hear it!

--
Cédric


Reply all
Reply to author
Forward
0 new messages