How to set Group name & dependency at runtime in TestNG

214 views
Skip to first unread message

Vidhya

unread,
May 22, 2014, 9:08:47 AM5/22/14
to testng...@googlegroups.com
Hi,
 
I am new to TestNG. I am Automating REST API.  I have method1() in class A.  I have created one suite that contains 5 tests say test name  1, 2, 3, 4, 5. These test will always invoke Method1() with different parameter. If test 2 fails test 3 has to skip remaining tests has to continue. How I have to set dependency for this? Please give any guidance or reference links.
 
Thanks,
Vidhya 

Ahamed Saifudeen

unread,
May 27, 2014, 9:46:10 PM5/27/14
to testng...@googlegroups.com
Hi Vidhya,

Are these five tests reside in same class?

If test3 has to be skipped, when test2 fails, you can follow the below sample code,

@Test
public void test1()
{
}

@Test
public void test2()
{
}

@Test((dependsOnMethods = { "test2" })
public void test3()
{
}

In this case, test3 will be skipped if test2 fails. If you want your test method to depend on many methods, you can use dependsOnGroups instead of dependsOnMethods.

Please refer to TestNG documentation for more details: http://testng.org/doc/documentation-main.html

Thanks,
Saif



--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to testng-users...@googlegroups.com.
To post to this group, send email to testng...@googlegroups.com.
Visit this group at http://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.

Vidhya

unread,
Jul 10, 2014, 4:03:37 AM7/10/14
to testng...@googlegroups.com
Hi Saif,
 
Thanks for your response.  But I have to create the group & its dependency at runtime. For example I have method1(string testName) in class A, I’ll invoke this method 1000 times with different parameter “testName”. So the group has to created at runtime with the “testName”  and based on the name dependency has to set for the test.
 
I have my question @ https://groups.google.com/forum/#!topic/testng-users/gCkvHFgmT58 . Could you please help me. I still did not get the solution for this problem.
 
Thanks,
Vidhya

SUBRAMANYESWARA RAO BHAVIRISETTY

unread,
Jul 10, 2014, 2:29:28 PM7/10/14
to testng-users
Hi Vidya,


>>>Thanks for your response.  But I have to create the group & its dependency at runtime. For example I have >>>method1(string testName) in class A, I’ll invoke this method 1000 times with different parameter >>>“testName”. So the group has to created at runtime with the “testName”  and based on the name >>>dependency has to set for the test.

   Why do you need groups for this? Can't you use data provider for this? This way you can invoke same method with different parameters.

~Subramanyam
--
Subramanyam

SUBRAMANYESWARA RAO BHAVIRISETTY

unread,
Jul 10, 2014, 2:29:29 PM7/10/14
to testng-users
Hi Vidya,


>>>Thanks for your response.  But I have to create the group & its dependency at runtime. For example I have >>>method1(string testName) in class A, I’ll invoke this method 1000 times with different parameter >>>“testName”. So the group has to created at runtime with the “testName”  and based on the name >>>dependency has to set for the test.

   Why do you need groups for this? Can't you use data provider for this? This way you can invoke same method with different parameters.

~Subramanyam


On Thu, Jul 10, 2014 at 1:03 AM, Vidhya <pknv...@gmail.com> wrote:



--
Subramanyam
Reply all
Reply to author
Forward
0 new messages