Query regarding dependsOnGroups

12 views
Skip to first unread message

Anupam Lalit

unread,
Aug 3, 2017, 7:49:39 AM8/3/17
to testng-users
HI All

My source code structure  is like below . I have 2 classes ClassA and ClassB with 1 method each.

public class ClassA {
@Test(groups = "ClassA")
public void methodA(){
System.out.println("in method A");

}
}

public class ClassB {

@Test(dependsOnGroups = "ClassA")
public void methodB() {
System.out.println("in method B");

}
}

Query :  with TestNGversionA.xml desired results are not coming but TestNGversionB.xml desired results are coming..Details below

with below xml(TestNGversionA.xml) , on methodA is getting executed and  methodB is getting skipped.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
<suite name="Test_Suite" verbose="2" parallel="tests" thread-count="1" time-out="120000">


<test name="Test ClassA" group-by-instances="true" parallel="none" thread-count="1">

<classes>
<class name="com.mycompany.app.inBuiltObserverPattern.ClassA"/>

<!--<class name="com.mycompany.app.inBuiltObserverPattern.ClassB"/>-->
</classes>

</test>


<test name="Test ClassB" group-by-instances="true" parallel="none" thread-count="1">

<classes>
<class name="com.mycompany.app.inBuiltObserverPattern.ClassB"/>
</classes>
</test>


</suite>

However , with below xml (TestNGversionB.xml)both methods are getting execueted in desired order i.e first methodA and then methodB

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
<suite name="Test_Suite" verbose="2" parallel="tests" thread-count="1" time-out="120000">


<test name="Test ClassA" group-by-instances="true" parallel="none" thread-count="1">

<classes>
<class name="com.mycompany.app.inBuiltObserverPattern.ClassA"/>

<class name="com.mycompany.app.inBuiltObserverPattern.ClassB"/>
</classes>

</test>


</suite>


⇜Krishnan Mahadevan⇝

unread,
Aug 3, 2017, 8:05:03 AM8/3/17
to testng...@googlegroups.com
The method in ClassB is dependent on another method that is part of ClassA.

As long as both these classes are part of the same test [ which is what your TestNGversionB.xml  contains] it would work.

But your first xml  (TestNGversionA.xml) doesn't adhere to this, which is why the second class is getting skipped.

Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"
My Scribblings @ http://wakened-cognition.blogspot.com/
My Technical Scribbings @ http://rationaleemotions.wordpress.com/

--
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+unsubscribe@googlegroups.com.
To post to this group, send email to testng...@googlegroups.com.
Visit this group at https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages