dependsonmethods not sequencing properly(jumping between classes)

classic Classic list List threaded Threaded
27 messages Options
12
Reply | Threaded
Open this post in threaded view
|

Re: dependsonmethods not sequencing properly(jumping between classes)

Arno Jost
The post was old but not solved imho.

I have the same problem as described in the original post AND a similiar situation as the one depicted by Endre (so having individual <test>-Tags is NOT an option).

@Cédric: the situation can easily be reproduced using the code snippet below.

I'd be really glad if the ordering could natively be turned to "per class atomicity"

Greets,
Arno


------------ ClassA.java --------------
package test;

import org.testng.annotations.Test;

public class ClassA {
       
   @Test
   public void testA1()
   {
      System.out.println ("testA1");
   }
   
   @Test
   public void testA2()
   {
      System.out.println ("testA2");
   }
   
   @Test(dependsOnMethods={"testA1","testA2"})
   public void testA3()
   {
      System.out.println ("testA3");
   }  
}

------------ ClassB.java --------------
package test;

import org.testng.annotations.Test;

public class ClassB {
       
   @Test
   public void testB1()
   {
      System.out.println ("testB1");
   }
   
   @Test
   public void testB2()
   {
      System.out.println ("testB2");
   }
   
   @Test
   public void testB3()
   {
      System.out.println ("testB3");
   }
}

------------ testng.xml --------------
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="TestSuite" parallel="none">
  <test name="MyTest">   
    <classes>
      <class name="test.ClassA"/>
      <class name="test.ClassB"/>
    </classes> 
  </test>
</suite>



------ Output -------
[TestNG] Running:
  /usr/users/arno/local_home/workspace/playground/src/test/testng_dependsOnOrdering.xml

testA1
testA2
testB1
testB3
testB2
testA3

===============================================
TestSuite
Total tests run: 6, Failures: 0, Skips: 0
===============================================

:-(
Reply | Threaded
Open this post in threaded view
|

Re: dependsonmethods not sequencing properly(jumping between classes)

Krishnan Mahadevan
Have you tried using preserve-order=true ?

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">

<suite name="Suite" parallel="false">

  <test name="Test" preserve-order="true">

    <classes>

      <class name="krishnan.mahadevan.ClassB"/>

      <class name="krishnan.mahadevan.ClassA"/>

    </classes>

  </test>

</suite>



[TestNG] Running:

  /Users/krmahadevan/testng.xml


testB1

testB2

testB3

testA1

testA2

testA3


===============================================

Suite

Total tests run: 6, Failures: 0, Skips: 0

===============================================



Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"


On Tue, Nov 15, 2011 at 6:06 PM, Jostar <[hidden email]> wrote:

The post was old but not solved imho.

I have the same problem as described in the original post AND a similiar
situation as the one depicted by Endre (so having individual <test>-Tags is
NOT an option).

@Cédric: the situation can easily be reproduced using the code snippet
below.

I'd be really glad if the ordering could natively be turned to "per class
atomicity"

Greets,
Arno


------------ ClassA.java --------------
package test;

import org.testng.annotations.Test;

public class ClassA {

  @Test
  public void testA1()
  {
     System.out.println ("testA1");
  }

  @Test
  public void testA2()
  {
     System.out.println ("testA2");
  }

  @Test(dependsOnMethods={"testA1","testA2"})
  public void testA3()
  {
     System.out.println ("testA3");
  }
}

------------ ClassB.java --------------
package test;

import org.testng.annotations.Test;

public class ClassB {

  @Test
  public void testB1()
  {
     System.out.println ("testB1");
  }

  @Test
  public void testB2()
  {
     System.out.println ("testB2");
  }

  @Test
  public void testB3()
  {
     System.out.println ("testB3");
  }
}

------------ testng.xml --------------
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="TestSuite" parallel="none">
 <test name="MyTest">
   <classes>
     <class name="test.ClassA"/>
     <class name="test.ClassB"/>
   </classes>
 </test>
</suite>



------ Output -------
[TestNG] Running:

/usr/users/arno/local_home/workspace/playground/src/test/testng_dependsOnOrdering.xml

testA1
testA2
testB1
testB3
testB2
testA3

===============================================
TestSuite
Total tests run: 6, Failures: 0, Skips: 0
===============================================

:-(
--
View this message in context: http://old.nabble.com/dependsonmethods-not-sequencing-properly%28jumping-between-classes%29-tp18150149p32847234.html
Sent from the testng-users mailing list archive at Nabble.com.

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To post to this group, send email to [hidden email].
To unsubscribe from this group, send email to [hidden email].
For more options, visit this group at http://groups.google.com/group/testng-users?hl=en.


--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To post to this group, send email to [hidden email].
To unsubscribe from this group, send email to [hidden email].
For more options, visit this group at http://groups.google.com/group/testng-users?hl=en.
Reply | Threaded
Open this post in threaded view
|

Re: dependsonmethods not sequencing properly(jumping between classes)

Arno Jost
I just did -> it works fine!
I'm really surprised that this option was not posted as a solution to the original post, ergo problem.

Greets,
Arno

<quote author="Krishnan Mahadevan">
Have you tried using preserve-order=true ?

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">

<suite name="Suite" parallel="false">

  <test name="Test" preserve-order="true">

    <classes>

      <class name="krishnan.mahadevan.ClassB"/>

      <class name="krishnan.mahadevan.ClassA"/>

    </classes>

  </test>

</suite>


[TestNG] Running:

  /Users/krmahadevan/testng.xml


testB1

testB2

testB3

testA1

testA2

testA3


===============================================

Suite

Total tests run: 6, Failures: 0, Skips: 0

===============================================



Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening
or in love with someone else!"


Reply | Threaded
Open this post in threaded view
|

Re: dependsonmethods not sequencing properly(jumping between classes)

Krishnan Mahadevan
Maybe this feature was added to testng much after the question was raised.

Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"


On Tue, Nov 15, 2011 at 9:58 PM, Jostar <[hidden email]> wrote:

I just did -> it works fine!
I'm really surprised that this option was not posted as a solution to the
original post, ergo problem.

Greets,
Arno


Have you tried using preserve-order=true ?

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">

<suite name="Suite" parallel="false">

 <test name="Test" preserve-order="true">

   <classes>

     <class name="krishnan.mahadevan.ClassB"/>

     <class name="krishnan.mahadevan.ClassA"/>

   </classes>

 </test>

</suite>


[TestNG] Running:

 /Users/krmahadevan/testng.xml


testB1

testB2

testB3

testA1

testA2

testA3


===============================================

Suite

Total tests run: 6, Failures: 0, Skips: 0

===============================================



Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening
or in love with someone else!"



--
View this message in context: http://old.nabble.com/dependsonmethods-not-sequencing-properly%28jumping-between-classes%29-tp18150149p32848629.html
Sent from the testng-users mailing list archive at Nabble.com.

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To post to this group, send email to [hidden email].
To unsubscribe from this group, send email to [hidden email].
For more options, visit this group at http://groups.google.com/group/testng-users?hl=en.


--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To post to this group, send email to [hidden email].
To unsubscribe from this group, send email to [hidden email].
For more options, visit this group at http://groups.google.com/group/testng-users?hl=en.
Reply | Threaded
Open this post in threaded view
|

Re: dependsonmethods not sequencing properly(jumping between classes)

Cédric Beust ♔-2
In reply to this post by Arno Jost
Note that preserve-order="true" is now the default, so I'm assuming you are not using the latest TestNG(?).

-- 
Cédric




On Tue, Nov 15, 2011 at 8:28 AM, Jostar <[hidden email]> wrote:

I just did -> it works fine!
I'm really surprised that this option was not posted as a solution to the
original post, ergo problem.

Greets,
Arno


Have you tried using preserve-order=true ?

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">

<suite name="Suite" parallel="false">

 <test name="Test" preserve-order="true">

   <classes>

     <class name="krishnan.mahadevan.ClassB"/>

     <class name="krishnan.mahadevan.ClassA"/>

   </classes>

 </test>

</suite>


[TestNG] Running:

 /Users/krmahadevan/testng.xml


testB1

testB2

testB3

testA1

testA2

testA3


===============================================

Suite

Total tests run: 6, Failures: 0, Skips: 0

===============================================



Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening
or in love with someone else!"



--
View this message in context: http://old.nabble.com/dependsonmethods-not-sequencing-properly%28jumping-between-classes%29-tp18150149p32848629.html
Sent from the testng-users mailing list archive at Nabble.com.

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To post to this group, send email to [hidden email].
To unsubscribe from this group, send email to [hidden email].
For more options, visit this group at http://groups.google.com/group/testng-users?hl=en.


--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To post to this group, send email to [hidden email].
To unsubscribe from this group, send email to [hidden email].
For more options, visit this group at http://groups.google.com/group/testng-users?hl=en.
Reply | Threaded
Open this post in threaded view
|

Re: dependsonmethods not sequencing properly(jumping between classes)

Arno Jost
I'm using v 6.2. I assume it was defined as default in 6.3, which came out something about a month ago?

<quote author="Cedric Beust">
Note that preserve-order="true" is now the default, so I'm assuming you are
not using the latest TestNG(?).

--
Cédric

Reply | Threaded
Open this post in threaded view
|

Re: dependsonmethods not sequencing properly(jumping between classes)

Kostya Hospodarysko
In reply to this post by Krishnan Mahadevan
I agree that this is a solution. But only for sequential tests.
But if user wants to run tests in parallel? As user could have a lot of classes, and each class could have few methods with one depends on another. 
Here is my simple maven project https://github.com/khospodarysko/testng-parallel.git.

And I run test with such testng xml:

<suite name="Parallel" parallel="classes" thread-count="1">
  <test name="Classes" preserve-order="false">
    <class name="com.lohika.parallel.T1" />
    <class name="com.lohika.parallel.T2" /> 
    <class name="com.lohika.parallel.T3" /> 
    <class name="com.lohika.parallel.T4" />
  </test>
</suite>

First output (each class has two methods, annotated by @Test only, there are no dependencies):
9 beforeClass T1
9 T1 1
9 T1 2
9 afterClass T1
9 beforeClass T2
9 T2 1
9 T2 2
9 afterClass T2
9 beforeClass T3
9 T3 1
9 T3 2
9 afterClass T3
9 beforeClass T4
9 T4 1
9 T4 2
9 afterClass T4

Methods of each class are executed as expected, at first methods of one class, then methods of seconds class and so forth.

But if we mark second method of class T2 as dependsOnMethod(method 1) then output is:
9 beforeClass T1
9 T1 1
9 T1 2
9 afterClass T1
9 beforeClass T2
9 T2 1
9 beforeClass T3
9 T3 1
9 T3 2
9 afterClass T3
9 beforeClass T4
9 T4 1
9 T4 2
9 afterClass T4
9 T2 2
9 afterClass T2

Notice that T2 2 is executed after class T3 and T4, Even more if we remove class T4 from suite, then T2 2 also is executed "at the end".

Question is: what does dependsOnMethod do that is changes order of execution?

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/testng-users/-/Mkqepp3T5KMJ.
To post to this group, send email to [hidden email].
To unsubscribe from this group, send email to [hidden email].
For more options, visit this group at http://groups.google.com/group/testng-users?hl=en.
12