Using group-by-instances="true" gives TestNGException

313 views
Skip to first unread message

Musaffir Lp

unread,
Aug 25, 2015, 6:20:19 AM8/25/15
to testng-users
Hi All,

I came across this behavior
I have 2 test classes as below :


=================================================
public class Test1 
{
@Test
public void first()
{
System.out.println("first-class1");
}
@Test
public void second()
{
System.out.println("second-class1");
}
}
================================================
AND

public class Test2 
{
@Test
public void first()
{
System.out.println("first-class2");
}
@Test
public void second()
{
System.out.println("second-class2");
}
}
================================================

And when i design my testNg xml as below and run it, i get org.testng.TestNGException:  No free nodes found in:[DynamicGraph 

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="Default suite">

  <test verbose="2" name="Default test1" group-by-instances="true">
    <classes>
             <class name="Test2"/>
            <class name="Test1"/>  
    </classes>
  </test> 
</suite>

The issue can be resolved by removing the attribute group-by-instances="true from the test tag
and if there is only one test class present in the test tag, then also there wont be any issue 

i know the default value of group-by-instances is false 
and i wanted to know the functionality of group-by-instances attribute , is it to group the same test class instances together ,and then to run the methods present in that class ? 
If we do not mention this attribute , then also the classes will be executed in the order as they are mentioned in the <test> tag
so what is the purpose of group-by-instances="true ?


Thanks & Warm Regards
Musaffir



Krishnan Mahadevan

unread,
Aug 26, 2015, 4:22:05 AM8/26/15
to testng...@googlegroups.com
group-by-instances attribute comes into relevance when you are working with Factories in TestNG.

TestNG provides an annotation called @Factory using which you can basically define your own Test Class (A class which houses one or more @Test annotated test methods). So lets assume that this test class has 2 or more test methods and you would want TestNG to execute all the @Test annotated test methods of a particular instance together, that is when you go for this attribute.

This attribute has effect only when used in conjunction with Factories in TestNG.
 

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...@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.

Musaffir Lp

unread,
Aug 27, 2015, 3:39:50 AM8/27/15
to testng-users
Thanks again Krishnan, I got it 

Warm Regards
Musaffir
Reply all
Reply to author
Forward
0 new messages