Home > Blockchain >  Classes in TestNg POM framework are not getting executed in Sequence
Classes in TestNg POM framework are not getting executed in Sequence

Time:06-27

I am creating Simple Page Object Model framework in Selenium Java. One .java class is one scenario. So if i write this in TestNg.xml it works fine for one scenario.

**<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "https://testng.org/testng-1.0.dtd">
<suite thread-count="1" name="Test Simple Suite" parallel="false">  
    <listeners>
     <listener class-name="com.proj.Listener.Listeners"></listener>
    </listeners>
  <test thread-count="1" name="Test Basic Scenario1" parallel="false">
    <classes>
      <class name="TC001_SampleCase"/>
    </classes>
  </test> <!-- Test -->
</suite> <!-- Suite -->**

However, when i write second class, it also start the execution of the same. Expected is, it should execute in sequence. Following testNg executes both classed in parallel

**<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "https://testng.org/testng-1.0.dtd">
<suite thread-count="1" name="Test Simple Suite" parallel="false">  
    <listeners>
     <listener class-name="com.proj.Listener.Listeners"></listener>
    </listeners>
  <test thread-count="1" name="Test Basic Scenario1" parallel="false">
    <classes>
      <class name="TC001_SampleCase"/>
      <class name="TC002_SampleCase"/>
    </classes>
  </test> <!-- Test -->
</suite> <!-- Suite -->**

Would be really helpful, if anyone from the community can help on this issue. Thanks! Also note, in both classes i have given priorities to @Test. TC001_SampleCase consists 20 @Test given Priority from 1 to 20 TC002_SampleCase consists 15 @Test given Priority from 21 to 35 TestNg version: 7.3 Selenium version: 3.141.59

CodePudding user response:

Can you try removing the Parallel Tag from Suite line. Just keep as below and try.

<suite thread-count="1" name="Test Simple Suite">  

CodePudding user response:

To executed test cases sequentially using testng.xml files, please pass

preserve-order="true"

  • Related