user3640657
user3640657

Reputation: 397

TestNG not ordering classes as specified in the testng.xml file

My testng.xml file looks like:

<suite name="Suite" parallel="none">
  <test name="Test">
    <classes>
      <class name="testng.Test1"/>

      <methods>
        <include name="Browse()"></include>
        <include name="Login()"></include>
        <include name="Reg()"></include>                      
      </methods>

      <class name="testng.Test2"></class>

    </classes>
  </test> <!-- Test -->

The output of Test1 is:

*Login 
Register 
Browse*

The output of Test2 is

2

But, when i run the testng.xml file, the output looks like:

*Login Register 2 Browse*.

So, before the Test1 is completed, it is picking the Test2 and printing the output.

How can we run it, so that Test1 is executed first completely, followed by Test2?

I tried using preserve-order="true" but it didn't work.

Upvotes: 0

Views: 85

Answers (1)

djinc
djinc

Reputation: 171

Not sure what exactly you are asking for here but according to your xml file, you should include your methods in your class before closing it.

<suite name="Suite" parallel="none">
<test name="Test">
    <classes>
        <class name="testng.Test1">
            <methods>
                <include name="Browse()"></include>
                <include name="Login()"></include>
                <include name="Reg()"></include>
            </methods>
        </class>
        <class name="testng.Test2"/>
    </classes>
</test> <!-- Test -->

This way all the methods in your "Test1" will run first and then rest of the tests will run.

Learn more here.

Upvotes: 1

Related Questions