@BeforeSuite Execution Problem

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

@BeforeSuite Execution Problem

amitaks2
This post was updated on .
Hi Cedric ,

Good Morning.

Today I faced one issue with execution order of @BeforeSuite method. Could you please help me in understanding this concepts.

I am trying for testNG annotations And I am facing weired scenario:

I have two java classes names as SmokeClassOne.java  and RegressionClassTwo.java  each class have @BeforeSuite annotated method. From testng.xml I  am trying to call these both the classes from test nade as:
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="Smoke Application One Suite">
<test name="TestNG Anotation1">
    <classes>
                  <class name="testNGTestCases.SmokeClassOne" ></class>
                  <class name="testNGTestCases.RegressionClassTwo" ></class>
  </classes>
</test>
</suite>


OUTPUT: @BeforeSuite Methods of both the classes are executing very first. But I am seeing that @BeforeSuite method from RegressionClassTwo is executing first then @BeforeSuite  of SmokeClassOne class. Why execution order is changed  ??  I think all the classes are loaded in to memory and then all the annotations should be executed for order in which they are being called ???

Please clear my doubts

ATTACHMENT :
RegressionClassTwo.java
SmokeClassOne.java
SmokeApplicationOne.xml
Reply | Threaded
Open this post in threaded view
|

Re: @BeforeSuite Execution Problem

吴亭
Currently, TestNG will sort it alphabetically before you start to use it.

Not sure if we can remove this sort part in the TestNG:
    //
    // Sort the nodes alphabetically to make sure that methods of the same class
    // get run close to each other as much as possible
    //
    //Collections.sort(nodes2);

Because TestNG will sort test methods again later by method interceptor, so I guess this may only work for config method.

BTW, I want to test if this update will affect current code, but I cannot successfully run this test-all suite xml file.

I just create a simple Main method and put this xml path as parameter and call TestNG.main, it directly return a npe to me during xml parsing process.

Any reason could be?

Br,
Tim

2015-05-13 19:26 GMT+02:00 amitaks2 <[hidden email]>:
Hi Cedric ,

Good Morning.

Today I faced one issue with execution order of @BeforeSuite method. Could
you please help me in understanding this concepts.

I am trying for testNG annotations And I am facing weired scenario:

I have two java classes names as SmokeClassOne.java  and
RegressionClassTwo.java  each class have @BeforeSuite annotated method. From
testng.xml I  am trying to call these both the classes from test nade as:
<!DOCTYPE suite SYSTEM &quot;http://testng.org/testng-1.0.dtd&quot;>
<suite name="Smoke Application One Suite">
<test name="TestNG Anotation1">
    <classes>
                  <class name="testNGTestCases.SmokeClassOne" ></class>
                  <class name="testNGTestCases.RegressionClassTwo" ></class>
  </classes>
</test>
</suite>


OUTPUT: @BeforeSuite Methods of both the classes are executing very first.
But I am seeing that @BeforeSuite method from RegressionClassTwo is
executing first then @BeforeSuite  of SmokeClassOne class. Why execution
order is changed  ??  I think all the classes are loaded in to memory and
then all the annotations should be executed for order in which they are
being called ???

Please clear my doubts…



--
View this message in context: http://testng.1065351.n5.nabble.com/BeforeSuite-Execution-Problem-tp21281.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 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 http://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 http://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: @BeforeSuite Execution Problem

Krishnan Mahadevan
Tim,
Where are you seeing this ? It would be good if you could please help elaborate a bit more.

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, May 14, 2015 at 1:28 AM, 吴亭 <[hidden email]> wrote:
Currently, TestNG will sort it alphabetically before you start to use it.

Not sure if we can remove this sort part in the TestNG:
    //
    // Sort the nodes alphabetically to make sure that methods of the same class
    // get run close to each other as much as possible
    //
    //Collections.sort(nodes2);

Because TestNG will sort test methods again later by method interceptor, so I guess this may only work for config method.

BTW, I want to test if this update will affect current code, but I cannot successfully run this test-all suite xml file.

I just create a simple Main method and put this xml path as parameter and call TestNG.main, it directly return a npe to me during xml parsing process.

Any reason could be?

Br,
Tim

2015-05-13 19:26 GMT+02:00 amitaks2 <[hidden email]>:
Hi Cedric ,

Good Morning.

Today I faced one issue with execution order of @BeforeSuite method. Could
you please help me in understanding this concepts.

I am trying for testNG annotations And I am facing weired scenario:

I have two java classes names as SmokeClassOne.java  and
RegressionClassTwo.java  each class have @BeforeSuite annotated method. From
testng.xml I  am trying to call these both the classes from test nade as:
<!DOCTYPE suite SYSTEM &quot;http://testng.org/testng-1.0.dtd&quot;>
<suite name="Smoke Application One Suite">
<test name="TestNG Anotation1">
    <classes>
                  <class name="testNGTestCases.SmokeClassOne" ></class>
                  <class name="testNGTestCases.RegressionClassTwo" ></class>
  </classes>
</test>
</suite>


OUTPUT: @BeforeSuite Methods of both the classes are executing very first.
But I am seeing that @BeforeSuite method from RegressionClassTwo is
executing first then @BeforeSuite  of SmokeClassOne class. Why execution
order is changed  ??  I think all the classes are loaded in to memory and
then all the annotations should be executed for order in which they are
being called ???

Please clear my doubts…



--
View this message in context: http://testng.1065351.n5.nabble.com/BeforeSuite-Execution-Problem-tp21281.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 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 http://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 http://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 http://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: @BeforeSuite Execution Problem

吴亭
Hi,

You can get it in Graph.java

Br,
Tim

2015-05-14 17:20 GMT+02:00 Krishnan Mahadevan <[hidden email]>:
Tim,
Where are you seeing this ? It would be good if you could please help elaborate a bit more.

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, May 14, 2015 at 1:28 AM, 吴亭 <[hidden email]> wrote:
Currently, TestNG will sort it alphabetically before you start to use it.

Not sure if we can remove this sort part in the TestNG:
    //
    // Sort the nodes alphabetically to make sure that methods of the same class
    // get run close to each other as much as possible
    //
    //Collections.sort(nodes2);

Because TestNG will sort test methods again later by method interceptor, so I guess this may only work for config method.

BTW, I want to test if this update will affect current code, but I cannot successfully run this test-all suite xml file.

I just create a simple Main method and put this xml path as parameter and call TestNG.main, it directly return a npe to me during xml parsing process.

Any reason could be?

Br,
Tim

2015-05-13 19:26 GMT+02:00 amitaks2 <[hidden email]>:
Hi Cedric ,

Good Morning.

Today I faced one issue with execution order of @BeforeSuite method. Could
you please help me in understanding this concepts.

I am trying for testNG annotations And I am facing weired scenario:

I have two java classes names as SmokeClassOne.java  and
RegressionClassTwo.java  each class have @BeforeSuite annotated method. From
testng.xml I  am trying to call these both the classes from test nade as:
<!DOCTYPE suite SYSTEM &quot;http://testng.org/testng-1.0.dtd&quot;>
<suite name="Smoke Application One Suite">
<test name="TestNG Anotation1">
    <classes>
                  <class name="testNGTestCases.SmokeClassOne" ></class>
                  <class name="testNGTestCases.RegressionClassTwo" ></class>
  </classes>
</test>
</suite>


OUTPUT: @BeforeSuite Methods of both the classes are executing very first.
But I am seeing that @BeforeSuite method from RegressionClassTwo is
executing first then @BeforeSuite  of SmokeClassOne class. Why execution
order is changed  ??  I think all the classes are loaded in to memory and
then all the annotations should be executed for order in which they are
being called ???

Please clear my doubts…



--
View this message in context: http://testng.1065351.n5.nabble.com/BeforeSuite-Execution-Problem-tp21281.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 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 http://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 http://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 http://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 http://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: @BeforeSuite Execution Problem

吴亭
Remove sort method will cause the problem after regression test....

6 testcases failed.


Br,
Tim

2015-05-14 20:03 GMT+02:00 吴亭 <[hidden email]>:
Hi,

You can get it in Graph.java

Br,
Tim

2015-05-14 17:20 GMT+02:00 Krishnan Mahadevan <[hidden email]>:
Tim,
Where are you seeing this ? It would be good if you could please help elaborate a bit more.

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, May 14, 2015 at 1:28 AM, 吴亭 <[hidden email]> wrote:
Currently, TestNG will sort it alphabetically before you start to use it.

Not sure if we can remove this sort part in the TestNG:
    //
    // Sort the nodes alphabetically to make sure that methods of the same class
    // get run close to each other as much as possible
    //
    //Collections.sort(nodes2);

Because TestNG will sort test methods again later by method interceptor, so I guess this may only work for config method.

BTW, I want to test if this update will affect current code, but I cannot successfully run this test-all suite xml file.

I just create a simple Main method and put this xml path as parameter and call TestNG.main, it directly return a npe to me during xml parsing process.

Any reason could be?

Br,
Tim

2015-05-13 19:26 GMT+02:00 amitaks2 <[hidden email]>:
Hi Cedric ,

Good Morning.

Today I faced one issue with execution order of @BeforeSuite method. Could
you please help me in understanding this concepts.

I am trying for testNG annotations And I am facing weired scenario:

I have two java classes names as SmokeClassOne.java  and
RegressionClassTwo.java  each class have @BeforeSuite annotated method. From
testng.xml I  am trying to call these both the classes from test nade as:
<!DOCTYPE suite SYSTEM &quot;http://testng.org/testng-1.0.dtd&quot;>
<suite name="Smoke Application One Suite">
<test name="TestNG Anotation1">
    <classes>
                  <class name="testNGTestCases.SmokeClassOne" ></class>
                  <class name="testNGTestCases.RegressionClassTwo" ></class>
  </classes>
</test>
</suite>


OUTPUT: @BeforeSuite Methods of both the classes are executing very first.
But I am seeing that @BeforeSuite method from RegressionClassTwo is
executing first then @BeforeSuite  of SmokeClassOne class. Why execution
order is changed  ??  I think all the classes are loaded in to memory and
then all the annotations should be executed for order in which they are
being called ???

Please clear my doubts…



--
View this message in context: http://testng.1065351.n5.nabble.com/BeforeSuite-Execution-Problem-tp21281.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 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 http://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 http://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 http://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 http://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.