Query regarding dependsOnGroups

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Query regarding dependsOnGroups

Anupam Lalit
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>


--
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 [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Query regarding dependsOnGroups

Krishnan Mahadevan
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/

On Thu, Aug 3, 2017 at 4:49 PM, Anupam Lalit <[hidden email]> wrote:
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>


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

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